Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
fortaleza40
Contributor III
Contributor III

Sort time 12 hours format AM/PM with expresion

Hello Comunity,

I have a time field with 24 hours format, i formatted to 12 hours using this expression:

Mod(Hour(DateTimeField),12)&' '&time(DateTimeField, 'TT') as Hour

But now when i sort the field numerical or ascending is in disorder, how can i create a custom sort by expression? or sort this correcly?

disorder.PNG

 

1 Solution

Accepted Solutions
lorenzoconforti
Specialist II
Specialist II

An option might be to use the dual function when you create the field; something like this:

 

dual( Mod(Hour(DateTimeField),12)&' '&time(DateTimeField, 'TT') , Hour(DateTimeField) )  as Hour

View solution in original post

3 Replies
tresesco
MVP
MVP

Try recreating hour field like:

Time(Frac(DateTimeField), 'h TT') as Hour

 

Then the sort order should work fine.

fortaleza40
Contributor III
Contributor III
Author

The chart broke after use that formula 😞 and the sort option disable, do you know other way to do the same?

lorenzoconforti
Specialist II
Specialist II

An option might be to use the dual function when you create the field; something like this:

 

dual( Mod(Hour(DateTimeField),12)&' '&time(DateTimeField, 'TT') , Hour(DateTimeField) )  as Hour