Change 'a.m' to 'AM'

transforming a now() expression using Datetime. there is no option to use the uppercase, non-dotted version of AM/PM. how do i fix this? here's my format string:

dd MM Y, HH:MM a

normally, you'd have %p in Python to fix this atrocity. do i stack another transform for this?? or is there something i'm missing?

Try setting a different locale on the transform. The style of the AM/PM marker is a function of the locale.

actually, i just pulled my head out of my butt and re-read the docs. my solve was to transform the expression via script thusly:

correctedTime = system.date.format(value, 'E, dd MMM Y, HH:MM a')
return correctedTime

our locale IS set to the correct format, it was the first thing i double-checked (thanks regardless :+1:). for some reason, doing it this way just fixes the case problem. :man_shrugging:

i was going to delete this post because i felt stupid (a regular thing), but you replied and now we're here. :smiley:

As previously discussed, prefer expressions over scripts when possible, and this case is definitely possible. system.date.format and the dateFormat expression are both very thin wrappers over the underlying Java date formatting operations - so swap your script for a dateFormat expression and it should keep working and be faster.

1 Like

yeah. i just tipped to that and a heartbeat later: your post. :+1: thanks guys! :smiley:

for completion sake and for future numbskulls like me:

dateTime(now(), 'E, d MMM Y, HH:MM a')
# yeilds:  Mon, 1 Jan 2200, 2:00 PM