How do I merge two Date and time attributes?

1
I have two date and time fields that I like to merge. From one DateTime I need the date, of the other DateTime only the time. for example: 1/1/1970 14:30 and 11/05/2017 00:00   How do I merge these two such that I can get 11/05/2017 14:30? Thank you in advance
asked
1 answers
6

Hi Mark,

One way to do it is to use a combination of parseDateTime and formatDateTime

 

​e.g. you have two DateTime variables $Date and $Time
and you want to take the date component from $Date and the time component from $Time

$DateTime = parseDateTime(formatDateTime($Date,'MM-dd-yyy')+' '+formatDateTime($Time,'hh:mm:ss'),'MM-dd-yyy hh:mm:ss')

Not sure if you need to use the UTC versions of parse and format or not, I guess it would depend on whether your dateTime attributes are localized.

I hope this helps,
-Andrej

 

Disclaimer: I haven't tested this. :) 

answered