xsharp.eu • Is there a format for DATETIME literals???
Page 1 of 1

Is there a format for DATETIME literals???

Posted: Tue Apr 23, 2019 4:34 pm
by Anonymous
In a recent post, I answered my own question about DATE literals... So, I'm clear on that now.

Now, please tell me if there is a format/syntax for a DATETIME literal??
I even looked in the online Help and I didn't see DateTime listed as a data type.

Would it be something like this??

Code: Select all

dtDateTime := 2019.04.23 12:00:00

Is there a format for DATETIME literals???

Posted: Tue Apr 23, 2019 5:48 pm
by FFF
As far as my googling went, it seems there is NO literal in .net...
There IS a format for VB: #2015-12-18 14:30# or #12/18/2015 14:30#
but this does not work in X# (neither in C#)

Karl

Is there a format for DATETIME literals???

Posted: Tue Apr 23, 2019 5:54 pm
by robert
Matt,
No, the best you can do is

dtDateTime := DateTime{2019,4,23,12,0,0,0}

We could add something like this in the future

2019.04.23-12:00:00.00

A literal format with an embedded space maybe difficult.
Robert

Is there a format for DATETIME literals???

Posted: Tue Apr 23, 2019 6:13 pm
by FFF
Robert,
cool. IMO, the "actual" format doesn't matter, as long as it is "readable".
Would bring X# ahead of C# :)

Is there a format for DATETIME literals???

Posted: Tue Apr 23, 2019 6:23 pm
by FoxProMatt
Robert - This format you showed is good enough for me... I just wasn't sure if there are any literal or not, so that's why I asked.

Don't go peppering up the language just because I asked about it, unless you see the need or benefit. I was just looking for any way to create a DateTime explicitly, and you showed me how.

Thanks.

Code: Select all

dtDateTime := DateTime{2019,4,23,12,0,0,0}