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.
LVL 1
jjrr007Asked:
Who is Participating?
 
Cornelia YoderArtistCommented:
SELECT * FROM Table WHERE ADDDATE(Datefield, INTERVAL 1 YEAR) > NOW()
0
 
sleepyorionCommented:
Use this

SELECT YOUR_COLUMN_NAME FROM YOUR_TABLE
WHERE YOUR_COLUMN_NAME >  SYSDATE - 365

*Replace 365 with any amount of date you wish*
0
 
jjrr007Author Commented:
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
0
 
jjrr007Author Commented:
yodercm,

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

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.