November 30, 2022 at 5:38 pm
Hello all
I have this selected column :
convert(TT.horas, Time) AS TimeTT,
this column can have values like 08:00:00, 04:30:00, 05:50;00 etc, and I need to apply an hourly rate for each row, for example 40€.
My question is what is the best format for that column to accomplish this. Before the convert, this column is text.
I've tried unix_timestamp, time_to_sec and DateTimeToNumberDemo. None of this worked.
Can you guys help me?
Thanks a lot in advance
November 30, 2022 at 5:48 pm
You need to truncate the time to the hour --e.g.,
dateadd(hour, datediff(hour, 0, convert(TT.horas, Time) ), 0)
You can then do whatever aggregation or calculations are required.
November 30, 2022 at 5:55 pm
Hello ratbak
It gives me an error code: 1582. Incorrect parameter count in the call to native function 'datediff'
I'm so sorry but I forgot to say that I'm doing this in MySql.
Any thoughts on this?
So sorry again
November 30, 2022 at 7:12 pm
Guys,
Got it! It works this way
TIME_TO_SEC(TT.horas)/60/60 AS TimeTT
Thanks a lot
January 5, 2023 at 10:10 am
This was removed by the editor as SPAM
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply