Link to home
Start Free TrialLog in
Avatar of jjrr007
jjrr007

asked on

Today's date filter- Oracle (My SQL)

I have a column which has date/time.  I want to the query to only show records in the past year from the date run (using something similar to getdate in MS SQL).  I am using MY SQL, but I think it will be similar to (if not the same as Oracle).  Thanks.
Avatar of sleepyorion
sleepyorion

Use this

SELECT YOUR_COLUMN_NAME FROM YOUR_TABLE
WHERE YOUR_COLUMN_NAME >  SYSDATE - 365

*Replace 365 with any amount of date you wish*
ASKER CERTIFIED SOLUTION
Avatar of Cornelia Yoder
Cornelia Yoder
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jjrr007

ASKER

My SQL took the Now() funtion.  

Unfortunately, It returned a syntax error with the using the sysdate.  

I can use the now() function but I need to be able to say go one year back.  Unforunately, the -365 and the adddate function didn't work.  Kindly advise
Avatar of jjrr007

ASKER

yodercm,

Your solution worked.  I just had to use -1 and change the > to <.  Thanks a lot.
You're welcome.  You might check out the SUBDATE which is exactly like ADDDATE but you won't need the minus sign :)