Mombu the Programming Forum sponsored links

Go Back   Mombu the Programming Forum > Programming > utilizing dates
User Name
Password
REGISTER NOW! Mark Forums Read

sponsored links


Reply
 
1 30th April 16:19
shawn
External User
 
Posts: 1
Default utilizing dates



I have a simple script that I was given that I run the first business day of
each quarter for the previous quarter. So, for the past year I manually
pass it a start date and a end date for the previous quarter. So, I ran it
on July 1st passing it 01-Apr-03 as the start date and 30-Jun-03 as the end
date. It was suggested to me that the script could be automated to
determine these dates itself since its always run on the first business day
of the quarter.
I'm just not sure where to find this functionality. Any suggestions would
be greatly appreciated!

Thanks,
Shawn
  Reply With Quote


  sponsored links


2 20th May 12:43
laly
External User
 
Posts: 1
Default utilizing dates



Hello,


I think this is working to get the starting and ending date :
SQL> select sysdate,
2 trunc(trunc(sysdate, 'Q')-1,'Q') start_date,
3 trunc(sysdate, 'Q')-1 end_date
4 from dual;

SYSDATE START_DA END_DATE
-------- -------- --------
22/07/03 01/04/03 30/06/03

If you want to automate some more, look at the package DBMS_JOB to launch
automatically your batch.

Regards,

Laly.


"Shawn" <spedwards@qwest.net> a écrit dans le message de news:
cc2Ta.92$ez2.88205@news.uswest.net...

of


it

end


day
  Reply With Quote
3 20th May 12:43
sybrand bakker
External User
 
Posts: 1
Default utilizing dates


try trunc(sysdate,'Q') or try add_months(trunc(sysdate,'YEAR'),<number
of quarters>*3). For the end of the quarter use the same expression
embedded in LAST_DAY(ADD_MONTHS(original expression,3))


Sybrand Bakker, Senior Oracle DBA

To reply remove -verwijderdit from my e-mail address
  Reply With Quote
4 20th May 12:44
guido konsolke
External User
 
Posts: 1
Default utilizing dates


Hi Shawn,

a little addition to what Laly and Sybrand
posted: due to the time part in a date field
you should set your end date to the first
day after the end of the quarter and then
subtract a single second from this value.
That makes it '30-Jun-03 11:59:59 PM', so
all records for the last day are retrieved.

Greetings,
Guido
  Reply With Quote
Reply


Thread Tools
Display Modes




Copyright © 2006 SmartyDevil.com - Dies Mies Jeschet Boenedoesef Douvema Enitemaus -
666