When I use this syntax: CDate ({HISTAS.TDATE})
to convert a string to a date I get the error: bad date format srting. The field in the database is a string set like this-yyyymmdd. Any help would be appreciated.
Is it a string or an 8 digit integer? Several programs, Macola and ACCPAC being the ones I am most familiar with, store their dates as 8 digit integers.
If this is the case go to the CD website and download the NumbertoDate UFL.
If that is not the case, you need to parse out the string as follows:
Date(ToNumber(Left({String},4)),ToNumber(mid({string},5,2)),ToNumber(Right({string},2))) Software Support for Macola, Crystal Reports and Goldmine
dgilsdorf@mchsi.com
Numbertodate({numberfield}) will do the trick if {numberfield} is an 8 digit integer in the YYYYMMDD format. Software Support for Macola, Crystal Reports and Goldmine
dgilsdorf@mchsi.com
WhilePrintingRecords;
NumberVar input := {A.ISDATE}; // or whatever your field name is
// This line checks for a minimum value, any value will work.
If input < 19590101 then Date (1959, 01, 01) else
Date ( Val (ToText (input, 0 , "" [1 to 4]),
Val (ToText (input, 0 , "" [5 to 6]),
Val (ToText (input, 0 , "" [7 to 8]) )
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.