Re: Query for 3 months back
Posted by:
greg dove
Date: January 08, 2013 09:23AM
Let me ask this
If I have a database with these values
id dte
1 9/1/2012
2 9/9/2012
3 10/1/2012
14 10/6/2012
5 10/7/2012
8 10/8/2012
4 10/9/2012
10 10/10/2012
11 10/11/2012
12 10/12/2012
13 10/13/2012
7 11/1/2012
6 11/7/2012
9 1/10/2013
And query this
SELECT `dte` , datediff( now( ) , `dte` ) AS period, now( )
FROM test1
WHERE DATE_SUB( NOW( ) , INTERVAL 3
MONTH ) < `dte`
I get this:
dte Ascending period now()
2012-10-09 91 2013-01-08 09:19:57
2012-10-10 90 2013-01-08 09:19:57
2012-10-11 89 2013-01-08 09:19:57
2012-10-12 88 2013-01-08 09:19:57
2012-10-13 87 2013-01-08 09:19:57
2012-11-01 68 2013-01-08 09:19:57
2012-11-07 62 2013-01-08 09:19:57
2013-01-10 -2 2013-01-08 09:19:57
Should the value 10/8/2012
come up?
Subject
Written By
Posted
Re: Query for 3 months back
January 08, 2013 09:23AM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.