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

Convert a String to a Date Value

Status
Not open for further replies.

kate8

Programmer
Feb 14, 2001
184
US
Hi all,
I think this should be a simple issue, but I am doing it in a tedious way.
The B-date in my database a string in this format "yyyymmdd", such as "20111209". Since my report need to compare it to the current date, so I need a date value. I have tried cDate and other functions, but I got errors. For example when I do
cdate( left({B-date},4),mid({B-date},5,2),right({B-date},2) ),I got "too many arguments have been given to this function". Now I create formulas for year, month and day, then it will let me use cDate or DateValue().
I am wondering if there is better way to do this convertion.
Thank you so much for any helps/suggestions!!
 
cdate(val(left({B-date},4)),val(mid({B-date},5,2)),val(right({B-date},2)))

-LB
 
lbass,
Thank you so much!!! It works perfectly.
You are great as always.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top