Hi,
I have a simple calendar table generated in SqlServer that I need to create in DB2, just a list of months between two dates. The MSS is
Code:
-- SQL Server version
-- Generate a calendar table containing the months from start to end date
WITH cte_months
AS
(
SELECT cast('2009-10-01' as datetime) AS aMonth -- parameter
UNION ALL
SELECT DATEADD(mm, 1, aMonth)
FROM cte_months
WHERE DATEADD(mm, 1, aMonth) < '2010-10-01' -- parameter
) select * from cte_months
which gives output
Code:
2009-10-01 00:00:00.0
2009-11-01 00:00:00.0
2009-12-01 00:00:00.0
2010-01-01 00:00:00.0
2010-02-01 00:00:00.0
2010-03-01 00:00:00.0
2010-04-01 00:00:00.0
2010-05-01 00:00:00.0
2010-06-01 00:00:00.0
2010-07-01 00:00:00.0
2010-08-01 00:00:00.0
2010-09-01 00:00:00.0
Can anyone help changing to DB2?
thanks