This forum is for the sole use of CRD users. ChristianSteven Software will not accept any responsibility for the contents.

General Forum
Start a New Topic 
Author
Comment
Constant to determine the last day of current month

Is there a way to make a constant that returns the last day of the current month, or even the first day of the next month? TIA!

Re: Constant to determine the last day of current month

Create a data item which contains the sql code required to return these calculations. e.g The sql for Last day of current month would be:

SELECT DATEADD(m,1,CAST(STR(datepart(month,getdate())) + '/01/' + STR(datepart(year, getdate())) as datetime)) - 1

You may need to modify the above slighly so that it returns in the format you need.

Then insert the data item into the bit of your schedule where you need it.

Re: Constant to determine the last day of current month

Tryin to do this against a DB2 db. Any Ideas?

Have this so far but cannot get it to work correctly.

SELECT DISTINCT
DATE(MONTH(current date)+1,'1',YEAR(current date))from TABLE

Re: Constant to determine the last day of current month

This will work -
SELECT DISTINCT DATE('2007' || '-' || '04' || '-' || '01') FROM Table

but this will not
SELECT DISTINCT DATE(CHAR(YEAR(current date)) || '-' || CHAR(MONTH(current date)) || '-' || '01') FROM Table

Maybe they just need to make a new CRD constant!!

Re: Constant to determine the last day of current month

CRD Constants - Last day of the month & First day of next month are available in Build 20070321 and above.

spanish french german
italian japanese chinese
  korean  
   
 User Forum

CRD