CToD() return NULL_DATE

This forum is meant for questions and discussions about the X# language and tools
Post Reply
boonnam
Posts: 88
Joined: Mon May 08, 2017 6:42 pm
Location: USA

CToD() return NULL_DATE

Post by boonnam »

I came across an unexpected result when trying to test our converted X# application.

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))
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
User avatar
robert
Posts: 4290
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

CToD() return NULL_DATE

Post by robert »

Boonnam,
Confirmed.
We will fix this for the next build.

Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
Chris
Posts: 4599
Joined: Thu Oct 08, 2015 7:48 am
Location: Greece

CToD() return NULL_DATE

Post by Chris »

It's fixed now!
Chris Pyrgas

XSharp Development Team test
chris(at)xsharp.eu
Post Reply