Best way to convert date?

Meeting place for R&R customers and clients to share tips and ideas. Post your questions, messages or problems here.
Post Reply
chibbert
Posts: 9
Joined: Tue Oct 10, 2017 12:44 pm

Best way to convert date?

Post by chibbert » Wed Apr 15, 2009 12:24 pm

[updated:LAST EDITED ON Apr-15-09 AT 12:34 PM (EST)]If my database only uses dates in the format CCYYMMDD and it stores these as a numeric, what is the best way to convert this to a normal mm/dd/yy or mm/dd//yyyy format?____I would like the output to be a usable true date/time field as opposed to a character field if at all possible.____What I mean is I would like to be able to calculate using other functions after it has been converted.____Thanks____Chris

gjshuger
Posts: 15
Joined: Tue Oct 10, 2017 12:44 pm

=> RE: Best way to convert date?

Post by gjshuger » Thu Apr 16, 2009 10:14 am

You could first use STR(numval,8) convert the numeric value to a string, e.g., "20090415", then use the pieces of the string in a CTOD function to convert to a date, like this:____CTOD( SUBS(strval,5,2) + "/" + SUBS(strval,7,2) + "/" + SUBS(strval,1,4) )__

Post Reply