RE: given day of the year.

  • From: "Jacques Kilchoer" <Jacques.Kilchoer@xxxxxxxxx>
  • To: <sjaffarhussain@xxxxxxxxx>, <oracle-l@xxxxxxxxxxxxx>
  • Date: Tue, 15 Feb 2005 10:20:16 -0800

Use date arithmetic. If you add a number to a date, the number equates
to number of days.
+ 1 = add one day
+ 1 / 24 = add one hour
Etc.
SQL> select
  2     trunc (sysdate, 'YYYY') as first_day_this_year,
  3     trunc (sysdate, 'YYYY') + 100 as one_hundredth_day_of_this_year,
  4     to_date ('2001/01', 'YYYY/MM') as first_day_2001,
  5     to_date ('2001/01', 'YYYY/MM') + 100 as
one_hundredth_day_of_2001
  6   from dual ;

FIRST_DAY_THIS_YEAR  ONE_HUNDREDTH_DAY_OF FIRST_DAY_2001
ONE_HUNDREDTH_DAY_OF
-------------------- -------------------- --------------------
--------------------
 2005/01/01 00:00:00  2005/04/11 00:00:00  2001/01/01 00:00:00
2001/04/11 00:00:00

SQL> 

-----Original Message-----
Jaffar_DBA

Could any one give me the script or sql for the following requirements:

If I need to know the 100th day of this year, like, If I pass value
100, want to extract the 100th day of the given year. Sunday 21,
March, 2005. something like that.



--
//www.freelists.org/webpage/oracle-l

Other related posts: