DInesh AG DInesh AG - 4 months ago 20
MySQL Question

How to get the DateTime with ROUND value?

In MySQL select query I'm getting difference between two date time fields like

01:30:00
.

Now I need to convert as
1.5
hrs similarly for all.

Example:


  • 01:15:00 to 1.25

  • 01:30:00 to 1.5

  • 01:45:00 to 1.75


JPG JPG
Answer

Use TIME_TO_SEC, try this:

select TIME_TO_SEC('01:30:00') / 3600

Demo Here