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 format as YYYYMM

Status
Not open for further replies.

vidar.freyr

Technical User
Jul 5, 2017
1
IS
I have a default value in a report as YYYYMM.

I run this report on the first day of each month.

Delfault value need´s be last month with this format YYYYMM

In the past I have used
=DateAdd(DateInterval.Month,DateDiff(DateInterval.Month,CDate("01/01/1900"),Now())-1,CDate("01/01/1900"))

But for this report I can't use this it needs to be YYYYMM
 
Not used Cdate before and is not recognised by my copy of MSSQL 2016
You could try changing your CDate section to

CDate('01/'+substring(datefield, 4,2)+'/'+substring(datefield, 1,4)

replace datefield with your field holding YYYYMM, I have assumed this is a string field, if a number then you will need to cast as string first.

Ian
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top