1
I would like to know how to make calculations with dates in Mysql.
Table:
ID | DataValidade (DATETIME)
1 | 2017-01-01 00:00:00
2 | 2017-05-01 00:00:00
3 | 2016-06-01 00:00:00
I need to return the records whose expiration date is 30 days from today. I need to return records whose expiration date is between periods.
Fez
SELECT * FROM tabela where DATE_SUB(DataValidade, 30)
but is returning error #1064
Can someone help me or send links where I have good examples I can study regarding mysql date operations?
1064 is syntax error, I suspect I’m missing unity, are 30 days, 30 months, 30 years etc?
– rray
@rray, initially it is 30 days, but operations can vary according to options, type 30 days, months and years
– lelopes
vc need to say for Mysql somehow that 30 are days :P
– rray