Forum Discussion
JeremyLahners
Qrew Cadet
Hey Doug, this definitely got me closer, especially for DateTime fields. Now I am just struggling with separate Date and Time fields. Any suggestions on how to combine a Date and Time field into one datetime object so I can apply strftime() to it?
Date: 2023-01-17
Time: 4:00 PM
Desired Output: 2023-01-17T16:00:00Z
------------------------------
Jeremy Lahners
LeadBaller
------------------------------
Date: 2023-01-17
Time: 4:00 PM
Desired Output: 2023-01-17T16:00:00Z
------------------------------
Jeremy Lahners
LeadBaller
------------------------------
DougHenning1
2 years agoCommunity Manager
Combine the date and time with space separator, then use time.parse to parse the combined string into a datetime value:
------------------------------
Doug Henning
------------------------------
{% set reportDate = "2023-01-16" %}
{% set reportTime = "4:37 pm" %}
{% set reportStart = time.parse(reportDate ~ " " ~ reportTime) %}
{{ reportStart.strftime("%FT%T.%f")[:-3] ~ "Z" }}
------------------------------
Doug Henning
------------------------------
- PrashantMaheshw2 years agoQrew Captain@Doug Henning
[:-3] is a neat example of right slicing. Thank You .
------------------------------
Prashant Maheshwari
------------------------------ - JeremyLahners2 years agoQrew CadetBeautiful solution! Thank you so much!
------------------------------
Jeremy Lahners
LeadBaller
------------------------------