syxx1337 Posted January 24, 2018 Share Posted January 24, 2018 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
DRW Posted January 24, 2018 Share Posted January 24, 2018 (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 January 24, 2018 by MadnessReloaded Link to comment
syxx1337 Posted January 24, 2018 Author Share Posted January 24, 2018 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
DRW Posted January 24, 2018 Share Posted January 24, 2018 Just now, syxx1337 said: Thanks for your reply, but then how can I add +1 month from now? Month + 1 Link to comment
kieran Posted January 24, 2018 Share Posted January 24, 2018 (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 January 24, 2018 by kieran Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now