I'm looking for an existing function to convert a string version of a DateNum and/or TimeNum to a DateTime, without having to pull it apart and put it back together in an acceptable string format before conversion to DateTime – I’ve looked at a most of the available DateTime <--> String functions, but can’t seem to find what I'm looking for.
I’d appreciate it if someone can point me to the AB docs if something already exists.
Suppose I have this scenario:
initDateTime = DateTime() ;
initDateNumStr = DateTimeToStr(initDateTime, mode = 1 ) ; // Converts the bar's DateTime to a string in DateNum() format
And a bit later on in the code, I need to convert a string version of a date into a DateNum or DateTime format, ie turning initDateNumStr back into a DateNum or DateTime.
What I've looked at so far is:
-
DateTimeConvert
: converts a DateTime to other numeric formats, but not to their string equivalents -
DateTimeFormat
: converts a DateTime to a string -
DateTimeToStr
: also converts a DateTime to a string -
StrToDateTime
: converts a string into a DateTime
It looks like StrToDateTime( ''string'' )
will do what I want, but the example suggests that the input string needs to be formatted in a particular way, eg ISO YYYY-MM-DD
What I was hoping for, was to be able to input the string version of DateNum straight into StrToDateTime()
without having to pre-format it.
One of the issues of reverse-engineering a DateNum, let alone its string version, is that the year component needs special treatment, due to the limitation of 7 significant digits of FLOATS used by AB when a DateTime is converted to a DateNum.