0
Good morning to you all! how do I, in a query in mysql, find the date related to 3 months ago?
0
Good morning to you all! how do I, in a query in mysql, find the date related to 3 months ago?
0
You can use the Sysdate function next to the interval for example:
SELECT (SYSDATE() - INTERVAL 3 MONTH) FROM DUAL
or leave the fixed number of days:
SELECT (SYSDATE() - 90) FROM DUAL
I would remove the FROM dual
since it does not have the same meaning in mySQL
. In mysql the table dual
to exist must be created and does not have the same properties as in Oracle
.
Browser other questions tagged mysql query date
You are not signed in. Login or sign up in order to post.
What do you mean? Your question is not very clear.
– Sam
You want to pick up any record that contains a date field (DATE OR DATETIME) that is EXACTLY 3 months ago?
– Sam
ok! So, here’s the deal, I’m going to mount a view in mysql. in this view, I want to bring every client I’ve talked to for over 3 months, but since it’s mysql, I don’t know what the syntax is to create a backdate that represents the date of 3 months ago... "select * from table Where call > date(strtotime("-3 months"),Y-m-d h:i:s) but by mysql I don’t know how to dynamically generate this date...
– Horacio Neto
Have you tried:
SELECT * FROM tabela where campo_datetime < date(NOW() - INTERVAL 3 MONTH)
?– Sam