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.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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
ASKER
yodercm,
Your solution worked. I just had to use -1 and change the > to <. Thanks a lot.
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 :)
SELECT YOUR_COLUMN_NAME FROM YOUR_TABLE
WHERE YOUR_COLUMN_NAME > SYSDATE - 365
*Replace 365 with any amount of date you wish*