Home » Other » Training & Certification » HELP:From todays date, determine previous month end calendar date
HELP:From todays date, determine previous month end calendar date [message #299219] Sun, 10 February 2008 20:57 Go to next message
icm63
Messages: 22
Registered: December 2007
Junior Member
Are they any functions that can dp this ....

From todays date, determine previous month end calendar date

So todays date is 2/11/2008, result would be 1/31/2008

Any ideas how to make this a functions. I am a newbie to functions. I know I can do this in a table and join, but seams a waste of space.

Please help
Re: HELP:From todays date, determine previous month end calendar date [message #299237 is a reply to message #299219] Mon, 11 February 2008 00:15 Go to previous messageGo to next message
hobbes
Messages: 173
Registered: January 2006
Senior Member
Quote:
I know I can do this in a table and join

I'd be interested to see how.

Re: HELP:From todays date, determine previous month end calendar date [message #299249 is a reply to message #299219] Mon, 11 February 2008 00:46 Go to previous messageGo to next message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
There are many ways to do it. Here are 2 simple ones:
- first day of current month (TRUNC) - 1
- last day (LAST_DAY) of previous month (ADD_MONTHS)

Regards
Michel

[Updated on: Mon, 11 February 2008 00:47]

Report message to a moderator

icon2.gif  Re: HELP:From todays date, determine previous month end calendar date [message #299252 is a reply to message #299219] Mon, 11 February 2008 00:57 Go to previous messageGo to next message
katiyar.shakti
Messages: 2
Registered: February 2008
Location: Delhi,India
Junior Member
Hi Dear,u can do through this...will work fine..

1* select sysdate,to_char(trunc(sysdate,'month')-1,'dd mon yyyy hh24:mi:ss') from dual
SQL> /

SYSDATE TO_CHAR(TRUNC(SYSDAT
--------- --------------------
11-FEB-08 31 jan 2008 00:00:00

------
Shakti

[Updated on: Mon, 11 February 2008 01:18] by Moderator

Report message to a moderator

Re: HELP:From todays date, determine previous month end calendar date [message #299261 is a reply to message #299252] Mon, 11 February 2008 01:17 Go to previous messageGo to next message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
Shakti,

You should read OraFAQ Forum Guide and especially "Responding to Posts" section:
Quote:
When responding to questions, if it is obviously a student with a homework assignment or someone else just learning, especially in the homework and newbies forums, it is usually best to provide hints or clues, perhaps links to relevant portions of the documentation, or a similar example, to point them in the right direction so that they will research and experiment on their own and learn, rather than providing complete solutions to problems. In cases where someone has a real-life complex work problem, or at least it may seem complex to them, it may be best to provide a complete demo and explanation.

You should also read "How to format your post?" section.
Make sure that lines of code do not exceed 80 characters when you format. Indent the code. Use the "Preview Message" button to verify.

Regards
Michel

[Updated on: Mon, 11 February 2008 01:18]

Report message to a moderator

Re: HELP:From todays date, determine previous month end calendar date [message #299405 is a reply to message #299219] Mon, 11 February 2008 21:06 Go to previous messageGo to next message
shankar muthusamy
Messages: 21
Registered: November 2006
Location: singapore
Junior Member
Hi
Try This
--last_day(add_months(trunc(sysdate),-1))
--add_months(to_date(to_char(add_months(sysdate,-1),
'RRRRMM'),'RRRRMM'),1)-1

Regards
Shankar
Re: HELP:From todays date, determine previous month end calendar date [message #299412 is a reply to message #299405] Mon, 11 February 2008 23:08 Go to previous message
Michel Cadot
Messages: 68716
Registered: March 2007
Location: Saint-Maur, France, https...
Senior Member
Account Moderator
What does this add to the previous answers but a bad expression?
Read and FOLLOW the OraFAQ Forum Guide.
Read my previous post.

Regards
Michel

[Updated on: Mon, 11 February 2008 23:09]

Report message to a moderator

Previous Topic: Data Blocks
Next Topic: what to do after OCA ??
Goto Forum:
  


Current Time: Thu Nov 21 15:01:42 CST 2024