Home » SQL & PL/SQL » SQL & PL/SQL » Oracle date function
Oracle date function [message #424807] Tue, 06 October 2009 01:48 Go to next message
krishna135
Messages: 3
Registered: September 2009
Location: Chennai
Junior Member
I need a where clause that will all the records from the previous year and up to todays date.

Since its the first of the year I want all of the data from 1 January 2004. My data set will build until the 31st of December of this year until it resets again on January 1st of next year. Am I clear?
Re: Oracle date function [message #424808 is a reply to message #424807] Tue, 06 October 2009 01:50 Go to previous messageGo to next message
Michel Cadot
Messages: 63810
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
Am I clear?

No.

Post a working Test case: create table and insert statements along with the result you want with these data.
Also always post your Oracle version with 4 decimals.

Before posting code, please ead OraFAQ Forum Guide, especially "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format.
Indent the code, use code tags and align the columns in result.
Use the "Preview Message" button to verify.

Regards
Michel
Re: Oracle date function [message #424809 is a reply to message #424807] Tue, 06 October 2009 01:50 Go to previous messageGo to next message
bmineonly
Messages: 5
Registered: October 2009
Location: karachi
Junior Member

u want the data from 2004 to date?
Re: Oracle date function [message #424819 is a reply to message #424809] Tue, 06 October 2009 02:23 Go to previous messageGo to next message
Michel Cadot
Messages: 63810
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
I want an example of what you want.
Not million rows, you do not need more than 10 or 20 rows to build a representative example.

Regards
Michel
Re: Oracle date function [message #424826 is a reply to message #424807] Tue, 06 October 2009 02:49 Go to previous message
JRowbottom
Messages: 5933
Registered: June 2006
Location: Sunny North Yorkshire, ho...
Senior Member
I'm a bit confused by your question, as the previous year wasn't 2004, it was 2008 (at least it was round here)

If you want to select dates from 1st january last year until the current date, you can use
WHERE <date_column> BETWEEN trunc(add_months(sysdate,-12),'YYYY') AND sysdate
Previous Topic: need help Column to rows
Next Topic: Table partitioning
Goto Forum:
  


Current Time: Fri Sep 30 03:47:45 CDT 2016

Total time taken to generate the page: 0.07975 seconds