Page 1 of 1
Previous Month Last Date
Posted: Wed Aug 19, 2009 10:48 pm
by Ashish
Hi,
How to get the last date of the previous month.?
Thanks
Ashish
Posted: Wed Aug 19, 2009 11:27 pm
by talk2shaanc
DateFromDaysSince(-1, stringtodate(right(0:MonthFromDate(CurrentDate()),2):'-':'01':'-': YearFromDate(CurrentDate()),"%mm-%dd-%yyyy"))
Posted: Wed Aug 19, 2009 11:33 pm
by dxk9
Does this give the date of last day or the 1st day of previous month? When I manipulate it, I get the 1st day of previous month. If its last day, can you explain me the logic?
Regards,
Divya
Posted: Thu Aug 20, 2009 2:31 am
by laknar
SELECT TRUNC(SYSDATE)-1 AS LAST_MONTH_END_DATE FROM DUAL in oracle
Posted: Thu Aug 20, 2009 3:06 am
by dxk9
Laknar,
Your query give yesterday's date only. Moreover I think the requirement is in datastage and not oracle.
Regards,
Divya
Posted: Thu Aug 20, 2009 3:12 am
by Sainath.Srinivasan
Posted: Thu Aug 20, 2009 3:16 am
by dxk9
In oracle, that query is fine. But I think Ashish requires in datastage. Correct me if I am wrong.
Regards,
divya
Posted: Thu Aug 20, 2009 3:30 am
by priyadarshikunal
talk2shaanc wrote:DateFromDaysSince(-1, stringtodate(right(0:MonthFromDate(CurrentDate()),2):'-':'01':'-': YearFromDate(CurrentDate()),"%mm-%dd-%yyyy"))
in datastage this should work fine.
this first derives the 1st day of current month and then subtracts 1 day from that.
in oracle sainaths code works fine.
Posted: Thu Aug 20, 2009 3:35 am
by dxk9
Thanks for the explanation priyadarshikunal.
Regards,
Divya
Posted: Thu Aug 20, 2009 4:23 am
by Ashish
priyadarshikunal wrote:talk2shaanc wrote:DateFromDaysSince(-1, stringtodate(right(0:MonthFromDate(CurrentDate()),2):'-':'01':'-': YearFromDate(CurrentDate()),"%mm-%dd-%yyyy"))
in datastage this should work fine.
this first derives the 1st day of current month and then subtracts 1 day from that.
in oracle sainaths code works fine.
Hi guys,
Thanks for the information
Thanks Ashish