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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with Dates

Status
Not open for further replies.

simeet7

Programmer
Sep 4, 2020
1
US
The below works in SQL Server but need it in DB2. Looking for two dates - last Sunday of previous month and last Saturday of current month.

SELECT DATEADD(day, DATEDIFF(day,'1900-01-07', DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE() - 30),30))/7*7,'1900-01-07') AS LAST_SUNDAY_PREVIOUS_MONTH
SELECT DATEADD(day, DATEDIFF(day,'1900-01-06', DATEADD(MONTH, DATEDIFF(MONTH, 0, Getdate()), 30)) / 7 * 7, '1900-01-06') AS LAST_SATURDAY_CURRENT_MONTH
 
after reading the manuals (you did search for them didn't you? db2 date functions) what has lead you to keep the same functions as used on SQL Server instead of using those specific to db2?

Regards

Frederico Fonseca
SysSoft Integrated Ltd

FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top