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 calculation - 12th of last month

Status
Not open for further replies.

galaxy0815

Technical User
Dec 27, 2006
39
US
Hi,

Can you please let me know if there is an easier way of calculation from todays date the 12.th of last month as this one here:

Code:
date(trim(Char(YEAR(CURRENT DATE - 1 MONTH)))||'-'|| trim(Char(MONTH(CURRENT DATE - 1 MONTH)))||'-12')

Looks so complex for this simple task. Thanks
 
That appears reasonably "easy" to me?

What might you prefer? As long as you only want 12th of last month (from today - either before or after midnight) what you hae should sufice.
 
You could go 'slightly' easier with:

SELECT CURRENT DATE - 1 MONTH - DAY(CURRENT DATE)DAYS + 12 DAYS
FROM SYSIBM.SYSDUMMY1

Which at least keeps everything as a date through the calculation.... but gets you the same result.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top