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

Convert string date "ddmmyy" to date value

Status
Not open for further replies.

nostra2000

IS-IT--Management
Aug 4, 2004
2
MX
Hi

I have a string in that represents a date in the following format "ddmmyy" I need to converted into its correponding date, but I havent been able to do it either by using Cdate or DTStoDate

Any ideas..

Thanks
 
You can try this in a formula:

Code:
cdate(left({table.date},2)&"/"&mid({table.date},3,2)&"/"&right({table.date},2))

~Brian
 
Sorry that should have been:

Code:
cdate (mid({table.date},3,2)&"/"&left({table.date},2)&"/"&right({table.date},2))

~Brian
 
You can probably do it on the database side as well using a SQL Expression, but as with most software solutions, it's dependent upon your version and edition of the software (which you didn't share).

Brian's solution looks sound, but you should show what you tried and what the results were (error, wrong date, or?).

-k
 
Thanks for the prompt response: This is my formula.
cdate(Trim (Left ({time.Work_Date},2 ))&"/"&Trim (right (trim(left({time.Work_Date},4)),2 ))&"/"&Trim (right ({time.Work_Date},2 )))

This is the formula that I have... a little different than yours, but I still get the same result

My original field has a string representing a date in the following manner 160804 been 16 the day 08 the month and 04 the year, but using the cdate formula the output result is 8/4/2016 as if it was taking the 16 for the year the 04 for the day and 08 for the day.

How can I get the correct date in a date value and not as text... for future calculations it would be easier to handle dates instead of text..

Thanks for your input

synapsevamire... you are right sorry for the missing information.. on the back end I have SQL Server 2000 and from the front end I have crystal reports Pro V10
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top