Jump to content

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


syxx1337

Recommended Posts

Posted

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)

 

Posted (edited)
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

tJ5zeFm.gif

Proud owner and developer of ZNEXT: Aftermath.

Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience.

Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. 

Español, Pусский, Türk, عربى, Polski, Português

IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB

Posted
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?

Posted
Just now, syxx1337 said:

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

Month + 1

tJ5zeFm.gif

Proud owner and developer of ZNEXT: Aftermath.

Enter a post-apocalyptic San Andreas and fight over 30 types of enemies and bosses with varying difficulties and skills, improve and customize your character by leveling up, completing challenges and a solid lootbox system with no Pay-to-Win mechanics that will break your experience.

Meet new characters, creatures and weapon metas, experience an innovative combo-based melee system, or join our solid PvP modes to show other survivors who’s boss. 

Español, Pусский, Türk, عربى, Polski, Português

IP: mtasa://104.36.110.227:22003 - Discord: https://discord.gg/CxMxjvC5pB

Posted (edited)

See where you have

time.month

Add this bit of code where you want to add +1

time.month = (tonumber(time.month)) + 1 --This should do time.month = the month converted to a number plus one
Edited by kieran

 

 

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...