Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Help 1

Status
Not open for further replies.

strom99

MIS
Nov 28, 2000
126
US
I have the following

select
cast(substr(date,1,8)||'01' as date format 'yyyy-mm-dd') as FirstDay,

cast(substr(add_months (cast (substr(date,1,8)||'15' as date format 'yyyy-mm-dd'), 1),1,8)||'01' as date format 'yyyy-mm-dd') - 1 as LastDay,

cast(substr(add_months(date,-1),1,8)||'01' as date format 'yyyy-mm-dd') FirstDayLM

Need one more to determine the last day of the last month, any ideas?

Thanks Much
 
How do I accomplish that, I did not write the above so I am a little confused.

Thanks
 
Need to calculate the Last Day of the last month.
I have the following

select
cast(substr(date,1,8)||'01' as date format 'yyyy-mm-dd') as FirstDayCurrentMonth,

cast(substr(add_months (cast (substr(date,1,8)||'15' as date format 'yyyy-mm-dd'), 1),1,8)||'01' as date format 'yyyy-mm-dd') - 1 as LastDayCurrentMonth,

cast(substr(add_months(date,-1),1,8)||'01' as date format 'yyyy-mm-dd') FirstDayLastMth


Thanks
 
Take the first attribute of the select statement you have and subtract 1.

(cast(substr(date,1,8)||'01' as date format 'yyyy-mm-dd')) -1 as Last Day of Last Month,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top