[DateUtils] Why text output?

[DateUtils] Why text output?

  
Forge Component
(4)
Published on 2015-12-15 by Pedro Domingues
4 votes
Published on 2015-12-15 by Pedro Domingues
Why is this outputting text for CurrDateTimeMS() instead of a DateTime type? Is there something I shoul know before adding a function that does it in DateTime type?

J.Ja
DateTime type does not include the miliseconds resolution.

I'd say that's the reason for returning text.

Joel Alexandre wrote:
DateTime type does not include the miliseconds resolution.

I'd say that's the reason for returning text.
 
I forgot that DateTime doesn't really have MS (they are in the DB, but not really used). I think you're right here. 

J.Ja

Solution
Actually the datetime datatype does keep the milliseconds, just the Text conversions do not print them.

Comparisons will still work and if you send the value to the database or to an integration (SOAP, REST, extension, ... ) the milliseconds will be sent as well.

Also in the next major version of the platform there will be a new Builtin function (that will replace around 8 of the existing functions) for date time format to text that will allow printing the milliseconds.

Regards,
João Rosado
Solution

João Rosado wrote:

Actually the datetime datatype does keep the milliseconds, just the Text conversions do not print them.

Comparisons will still work and if you send the value to the database or to an integration (SOAP, REST, extension, ... ) the milliseconds will be sent as well.

Also in the next major version of the platform there will be a new Builtin function (that will replace around 8 of the existing functions) for date time format to text that will allow printing the milliseconds.

Regards,
João Rosado


en what major version would that be and what function?

SyntaxEditor Code Snippet

FormatDateTime(CurrDateTime(),"yyyy-MM-dd HH:mm:ss.fff")

has got no effect...(well it only shows 000 at the end)

Hi J,


Thats because the CurrDateTime() does not include the milliseconds. But if your date comes from an external source like an integration, from doing a Datetime.Now in an extension or even in a new Date() Javascript Node, the miliseconds are preserved and can be converted to text with that FormatDateTime function.


So like Justin said, if that function CurrDateTimeMS() returned a DateTime it would have the milliseconds, just that anyone writing that to a screen as a Text would need to use the FormatDateTime explicitly as the default text conversion does not output it.


FormatDateTime was introduced in version 10 and replaces (with an automatic upgrader) all the other date formatting builtin functions that were in previous versions.


Regards,
João Rosado