Unix Technical Forum

Question - Passing a date

This is a discussion on Question - Passing a date within the Oracle Miscellaneous forums, part of the Oracle Database category; --> Hi, I have been asked to author a report for Finance (having not done this before) and I want ...


Go Back   Unix Technical Forum > Database Server Software > Oracle Database > Oracle Miscellaneous

Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-08-2008, 10:16 AM
VB
 
Posts: n/a
Default Question - Passing a date

Hi,

I have been asked to author a report for Finance (having not done this
before) and I want to pass set up a view which will take the assembled
data from 01/09/05 until the End of the month previous ie 31/08/06 but
up until Midnight. THen next month for September.

Is there a way to get the previous month's date by using TO_DATE
Sysdate and minusing the month by 1 (The report will always be run on
the 1st of the next month).

Any and all help would be appreciated.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 04-08-2008, 10:16 AM
Martin T.
 
Posts: n/a
Default Re: Question - Passing a date

VB wrote:
> Hi,
>
> I have been asked to author a report for Finance (having not done this
> before) and I want to pass set up a view which will take the assembled
> data from 01/09/05 until the End of the month previous ie 31/08/06 but
> up until Midnight. THen next month for September.
>
> Is there a way to get the previous month's date by using TO_DATE
> Sysdate and minusing the month by 1 (The report will always be run on
> the 1st of the next month).
>
> Any and all help would be appreciated.


Is this helpful? ...

select sysdate now, add_months(sysdate, -1) one_month_before from dual

best,
Martin

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 04-08-2008, 10:16 AM
Mark D Powell
 
Posts: n/a
Default Re: Question - Passing a date


Martin T. wrote:
> VB wrote:
> > Hi,
> >
> > I have been asked to author a report for Finance (having not done this
> > before) and I want to pass set up a view which will take the assembled
> > data from 01/09/05 until the End of the month previous ie 31/08/06 but
> > up until Midnight. THen next month for September.
> >
> > Is there a way to get the previous month's date by using TO_DATE
> > Sysdate and minusing the month by 1 (The report will always be run on
> > the 1st of the next month).
> >
> > Any and all help would be appreciated.

>
> Is this helpful? ...
>
> select sysdate now, add_months(sysdate, -1) one_month_before from dual
>
> best,
> Martin


Besides the add_months function Martin pointed out I would like to
point out that the job might not always be submitted on the first due
to holidays, weekend schedules etc... so you might want to use
trunc(sysdate,'MM') which will set the result to midnight on the first
of the current month. Then the exact date the job is submitted will
not matter and you can code < trunc(sysdata.'MM') to always stop
processing with 23:59:59 of the prior month.

The last_day function may also prove useful to you at some time in the
future. You can find the DATE manipulation functions in the SQL
manual.

HTH -- Mark D Powell --

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 09:46 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com