I want to convert Milliseconds to DateTime how can I do this?
Hi Halit,
There's no such Action available out of the box. However, if you have the offset of the milliseconds, e.g. 1970-01-01, you could use the built-in AddSeconds Function like this:
AddSeconds(#1970-01-01#, MilliSeconds / 1000)
Kilian Hekhuis wrote:
I use it like this:
SyntaxEditor Code Snippet
AddSeconds(DurationTable.List.Current.Duration.SpanStart, DurationTable.List.Current.Duration.Duration / 1000)
the spanstart is an datetime and it saves the date when the duration is saved in DB. The duration is an long integer and it gives the duration in milliseconds. If I use youre function I just get: 08-10-2019 21:13:09 but I want the calculation between mine spanStart and SpanEnd and show it in Time or DateTime
Thank You it worked for me instead of span start I needed to set NullDate()
Thanks, it helped me a lot in a conversion
Hi Halit!You could convert the milliseconds into seconds into bigger time units like seconds, minutes, hours, days or even years using an Assign variable. Convert it to Text data type then use the appropriate built-in DataConversion functions.
Reference:https://success.outsystems.com/Documentation/11/Reference/OutSystems_Language/Logic/Built-in_Functions/Data_ConversionKind regards,Joseph Enriquez
@Joseph: I already gave Halit the solution. Converting anything to Text and back just for conversion is always bad practice, but in this case I can't see how it would help at all.
Hi Kilian!I wasn't refreshing the Forums while I was typing out my reply to Halit's question. My apologies.Kind regards,Joseph Enriquez
That seems to make sense :). Glad I could be of help!