Page 1 of 1

Best way to convert date?

Posted: Wed Apr 15, 2009 12:24 pm
by chibbert
[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

=> RE: Best way to convert date?

Posted: Thu Apr 16, 2009 10:14 am
by gjshuger
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) )__