How to apply rates in a time column

  • 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

  • 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.

  • 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


  • Guys,

    Got it! It works this way

    TIME_TO_SEC(TT.horas)/60/60 AS TimeTT

    Thanks a lot

  • 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