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!

Convert a String to A Date

Status
Not open for further replies.

SDS100UK

MIS
Jul 15, 2001
185
GB
Hi,

I have data in a string format. It is a very specific timestamp....but all I want is to convert it to DD/MM/YYYY format.

A typical string will be -
2002-12-30-18.18.36.951257. So it is in the format of "YYYY-MM-DD-HH.NN.SS.XXXXXX" (X BEING MILISECONDS)

All I want is the format as DD/MM/YYYY and as a date.

This must be possible....but I have no idea how.

Many thanks in advance


Steven
 
If it's always your first 10 characters that make up the date (i.e. single integer months and days take up two characters - 2002-01-01 as opposed to 2002-1-1), then you can use:

Date(Left({YourString},10))

Then you can right click the field, and set your date format to what you want it to be.

Naith
 
Try the CDate() function first.

If that doesn't work, it should be easy to grab the first portion of the string and convert it to a format that CDate() can handle.

Cheers,
- Ido CUT, Visual CUT, and DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top