Quantcast
Channel: Toad for IBM DB2 Forum - Recent Threads
Viewing all articles
Browse latest Browse all 389

RE: DB2 - First And Last Day Of Previous Quarter

$
0
0

Does this work for you?  It's kinda of sloppy and only returns 1 date, but you can tweak it I think.  The key I think is you need to use sysibm.sysdummy1 in z/OS.  It's sad that z/OS lacks behind alot of features of T-SQL in SQL Server...

with cteDate as (
Select date('04/21/2017') as d
from SYSIBM.sysdummy1
)
,StarDate as
(
SELECT d - DAYOFYEAR(d) DAYS + ((QUARTER(d) - 1) * 3) MONTHS - 3 MONTHS + 1 DAY as DateValue
FROM cteDate
)
Select * from StarDate

--This will return a value of 01/01/2017


Viewing all articles
Browse latest Browse all 389

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>