Is there a format for DATETIME literals???

This forum is meant for questions and discussions about the X# language and tools
Post Reply
Anonymous

Is there a format for DATETIME literals???

Post 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
FFF
Posts: 1522
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

Is there a format for DATETIME literals???

Post 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
Regards
Karl
(on Win8.1/64, Xide32 2.19, X#2.19.0.2.)
User avatar
robert
Posts: 4225
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

Is there a format for DATETIME literals???

Post 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
XSharp Development Team
The Netherlands
robert@xsharp.eu
FFF
Posts: 1522
Joined: Fri Sep 25, 2015 4:52 pm
Location: Germany

Is there a format for DATETIME literals???

Post by FFF »

Robert,
cool. IMO, the "actual" format doesn't matter, as long as it is "readable".
Would bring X# ahead of C# :)
Regards
Karl
(on Win8.1/64, Xide32 2.19, X#2.19.0.2.)
FoxProMatt

Is there a format for DATETIME literals???

Post 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}
Post Reply