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

Convert Sring Into Date Fomat

Status
Not open for further replies.

MadMax7

MIS
Feb 17, 2004
62
GB
I hope some one can help

I currently get sent a table daily that has a field (Trans date)that is formated as text and has dates in the format 23May2005. what i need to be able to do is convert this date into a correct date format ie 22/05/2005 so that i can query the data using a calender control.

 
Hi

try this

Make a Query based on your table, include a caculated column:

ADate:CDate(left(txtdate,2)& "/" & Mid(txtdate,3,3) & "/" & mid(txtDate,6,4))

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Ken

the initial part of the query works fine but i was wondering if there is a way to change the number of characters it looks at in the mid section of the code automatically for example

for next month the data is going to start to say 01June2005 so i will need to look at the middle 5 characters
 
Quick and dirty (typed, untested):
ADate:CDate(Left(txtdate,2) & "/" & Mid(txtdate,3,InStr(3,txtdate,"2")-3) & "/" & Right(txtdate,4))

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Perhaps simpler:
ADate: CDate(Left(txtdate,2) & "/" & Mid(txtdate,3,Len(txtdate)-6) & "/" & Right(txtdate,4)

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top