Home » Other » Training & Certification » HELP:From todays date, determine previous month end calendar date
HELP:From todays date, determine previous month end calendar date Sun, 10 February 2008 20:57
 icm63 Messages: 22Registered: 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.

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
 hobbes Messages: 173Registered: 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
 Michel Cadot Messages: 65144Registered: March 2007 Location: Nanterre, France, http://... Senior MemberAccount 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

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
 katiyar.shakti Messages: 2Registered: 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
 Michel Cadot Messages: 65144Registered: March 2007 Location: Nanterre, France, http://... Senior MemberAccount 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.

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
 shankar muthusamy Messages: 21Registered: November 2006 Location: singapore Junior Member
Hi
Try This
'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
 Michel Cadot Messages: 65144Registered: March 2007 Location: Nanterre, France, http://... Senior MemberAccount Moderator

Regards
Michel

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

Report message to a moderator

 Previous Topic: Data Blocks Next Topic: good intro book for sql server developer?
Goto Forum:

Current Time: Sun Aug 20 21:55:57 CDT 2017

Total time taken to generate the page: 0.04274 seconds