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

Converting a string into a date

Status
Not open for further replies.

KidFix

Programmer
Feb 7, 2002
60
US
Hi

Okay I've created a function that works out the date of the last day of the current month, but it returns it as a string. How can I convert this into a date?

I can arrange the string to a variety of formats such as:

31/07/2002
07/31/2002
31,07,2002
July 31, 2002
etc.

and I'm using IsDate(String) to return if the string can be converted (using CDate or # string #), but no format I've used will return true. Can anyone help?

Thanks in advance
Mark
 
If you want a formula to return the last day of the current month as a date, use this:

Dateadd("m",1,Date(Year(CurrentDate),Month(CurrentDate),1)-1

This will work for everything, even leap years. Software Training and Support for Macola, Crystal Reports and Goldmine
714-348-0964
dgilsdorf@mchsi.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top