SQL code to check for records 365 prior to today
SQL code to check for records 365 prior to today
(OP)
I would like to write some SQL to gather all of the records that meet the condition of todays date and everything prior to 365 days...
where field1 (DATE now <= 365 days)
can someone provide a better way of doing this in SQL? Database is Oracle 11g.
Thanks!
where field1 (DATE now <= 365 days)
can someone provide a better way of doing this in SQL? Database is Oracle 11g.
Thanks!
Dano
What's your major malfunction
RE: SQL code to check for records 365 prior to today
you might not like the ANSI SQL solution
r937.com | rudy.ca
Buy my new book Simply SQL from Amazon
RE: SQL code to check for records 365 prior to today
WHERE Field1 <= ADD_MONTHS(TRUNC(SYSDATE), 12) + (1-1/24/60/60)
SELECT SYSDATE AS Today,
ADD_MONTHS(TRUNC(SYSDATE), 12) + (1-1/24/60/60) AS OneYear
FROM DUal
TODAY ONEYEAR
-------------------- --------------------
22-JUL-2010 10:13:06 22-JUL-2011 23:59:59
RE: SQL code to check for records 365 prior to today
r937.com | rudy.ca
Buy my new book Simply SQL from Amazon