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

Convert string into date 2

Status
Not open for further replies.

Ann28

MIS
Apr 2, 2004
97
US
Hi

The date is a in a string format '200301'
How do I convert it into valid date format?

Thanks a lot:)
 
Assuming that your format is YYYYMM, this will return the first date of that month/year:

Date(Int(200401/100), 200401 Mod 100, 1)

-dave
 
Whoops, missed the "string" part...

Date(Int(val({Table.Field})/100), Val({Table.Field) Mod 100, 1)

-dave
 
Interesting approach, Dave, a star for creativity.

I would have used the brute force:

cDate("01/"+mid("200301",5)+"/"+left("200301",4))

-k
 
Thanks k,

I'm all too familiar with that YYYYMM format (we use it for Billing Periods).

-dave
 
I'd guess that the brute force method is faster since it doesn't do as much, but yours was clever, if not artistic.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top