Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hello everyone,
I'm stuck with a minor problem which i can't get through.
I have this expression that calculates difference in hours between two fields and convert them in integer datatype:
Num(Num#(Interval(Date(Date#(flight_operative_date,'YYYY-MM-DD hh:mm:ss'),'YYYY-MM-DD hh:mm:ss')-Date(Date#(create_reservation,'YYYY-MM-DD hh:mm:ss'),'YYYY-MM-DD hh:mm:ss'),'hh')))
When i use this dimension along with a measure in a bar chart, the sort numerically, as well as sort by expression, do not work.
Any suggestion?
It's impossible to say without seeing your sort settings. But I would start by simplifying the expression, that contains multiple interpretations and formattings, and that could cause the problem.
First, you should make sure that the timestamps are correctly interpreted in the script:
TimeStamp#(flight_operative_date,'YYYY-MM-DD hh:mm:ss') as flight_operative_date,
TimeStamp#(create_reservation,'YYYY-MM-DD hh:mm:ss') as create_reservation,
Then you can use the following, that will give the answer in hours and minutes:
Interval(flight_operative_date-create_reservation,'hh:mm:ss')
or if you want it in decimal hours:
Num(24*(flight_operative_date-create_reservation),'#0.00','.',',')