Jump to content

[HELP] How to add +1 month to current date [MYSQL]


syxx1337

Recommended Posts

Hello!

So, I want to put +1 month from now to the mysql data but it's just insert current date (2018.01.24).. why?!

date = string.format("%04d.%02d.%02d", time.year + 1900, time.month + 10, time.monthday )
	dbExec(connection, "UPDATE Identity SET expires=? WHERE value = ?", date,itemValue)

 

Link to comment
3 hours ago, syxx1337 said:

Hello!

So, I want to put +1 month from now to the mysql data but it's just insert current date (2018.01.24).. why?!


date = string.format("%04d.%02d.%02d", time.year + 1900, time.month + 10, time.monthday )
	dbExec(connection, "UPDATE Identity SET expires=? WHERE value = ?", date,itemValue)

 

Because the month range is 0-11 (It does not count months like that, it calculates months passed since January, so from January to February a month passes, then February is 1, from January to December, 11 months pass, so December is 11). Your script actually works since the month 1 is February.

Edited by MadnessReloaded
Link to comment
7 hours ago, MadnessReloaded said:

Because the month range is 0-11 (It does not count months like that, it calculates months passed since January, so from January to February a month passes, then February is 1, from January to December, 11 months pass, so December is 11). Your script actually works since the month 1 is February.

Thanks for your reply, but then how can I add +1 month from now?

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...