Convert Text to Date

A

AllyOop

What is the most efficient way to convert a text string in the form of
20060218 to a short date? Thanks!
 
O

Ofer

Assuming that the field always have the same formt
yyyymmdd

Try
cvdate(format(FieldName,"####/##/##"))
 
M

Marshall Barton

AllyOop said:
What is the most efficient way to convert a text string in the form of
20060218 to a short date? Thanks!

Short date is a format, which is irrelevant to the value.

To get a date value from that kind of string:

DateSerial(Left(txtstr,4), Mid(txtstr, 5,2), Right(txtstr,2)

To format the date value set the Format property of the text
box that you're using to display the value.
 
Top