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

Date

Status
Not open for further replies.

ShawnDT

Technical User
May 1, 2006
67
0
0
US
Good Morning Everyone.

I am trying to get a date minus 6 months of Current date but the date must be the begin day of the month.

Here is what I have

=Cstr(Month(Dateadd("m", -6, now())))& "/1/"& YEAR(Dateadd("m", -6, now()))

If I run this on preview. I get the property Default Value of report parameter Startdate doesnt have the expected type. I am a little stomp. If any guru's are around your help would be welcomed.
 
There may be more elegant ways to do this....but the following works for me.

=CDate(CStr(Month(DateAdd(DateInterval.Month, -6, Now()))) + "/01/" + CStr(Year(DateAdd(DateInterval.Month, -6, Now()))))

Jen
 
Thank you so much Jen for your kind attention. I modified my string with your inputs and it worked as well. Gosh I love this site, great tool for developers.

=CDate(Cstr(Month(Dateadd("m", -6, now())))& "/1/"& CStr(YEAR(Dateadd("m", -6, now()))))
 
A little easier to read and only has to do the DateAdd once...

Code:
=DateAdd("m", -6, DateSerial(Year(Now()), Month(Now()), 1))

=======================================
People think it must be fun to be a super genius, but they don't realize how hard it is to put up with all the idiots in the world. (Calvin from Calvin And Hobbs)

Robert L. Johnson III
CCNA, CCDA, MCSA, CNA, Net+, A+, CHDP
VB.NET Programmer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top