Re: trunc year

From: gym dot scuba dot kennedy at gmail <kennedyii_at_verizon.net>
Date: Thu, 23 Oct 2008 10:45:11 GMT
Message-ID: <XAYLk.3109$Rx2.2343@nwrddc01.gnilink.net>

<muhammaddzulkarnain_at_gmail.com> wrote in message news:e4851241-fa80-40ea-8052-9acb883a8d85_at_d31g2000hsg.googlegroups.com...
> Below is to get date range between a month
>
> SQL> select sysdate,
> 2 trunc(add_months(sysdate,-1),'month') start_date,
> 3 trunc(sysdate,'month')-1 end_date
> 4 from dual;
> SYSDATE START_DATE END_DATE
> ---------- ---------- ----------
> 21/10/2008 01/09/2008 30/09/2008
>
>
>
> how to get date range between a year?
>
> start_date = 20080101
> end_date = 20081231

select
to_date(to_char(sysdate,'yyyy')||'0101','yyyymmdd'), to_date(to_char(sysdate,'yyyy')||'1231','yyyymmdd') from dual; since the first day and the last day of a year are always the same month and day.
If you want the whole year then (and not ending midnight of 12/31 then end date

select
to_date(to_char(sysdate,'yyyy')||'0101','yyyymmdd'), to_date(to_char(sysdate+366,'yyyy'))||'0101','yyyymmdd') from dual; Received on Thu Oct 23 2008 - 05:45:11 CDT

Original text of this message