CToD() return NULL_DATE
Posted: Sun Jun 07, 2020 7:37 pm
I came across an unexpected result when trying to test our converted X# application.
In VO dDate would be "05/01/2020", but in X#, it is NULL_DATE. The reason is because of a space in front of the month. In this case cDate is actually " 5/01/2020". If I trim cDate before converting to date, then the result is the same as in VO.
This line get the correct date. I know VO is very forgiving. I don't mind trimming the string before trying to convert it to a date, but can you guys take a look at this? Thanks.
Boonnam
Code: Select all
local cDate as String
cDate := Str(5,2,0) + "/01/" + Str(2020,4,0)
local dDate as Date
dDate := CToD(cDate)
? dDate
Console.ReadKey()
In VO dDate would be "05/01/2020", but in X#, it is NULL_DATE. The reason is because of a space in front of the month. In this case cDate is actually " 5/01/2020". If I trim cDate before converting to date, then the result is the same as in VO.
Code: Select all
dDate := CToD(AllTrim(cDate))
Boonnam