Anyname Donotcare Anyname Donotcare - 5 months ago 15
SQL Question

How to check if two time values are in the same date

How to check two times if they are in the same date or not ?

For example

first- 08:00:00
second- 16:00:00



in the same date .





first- 20:00:00
second- 04:00:00



two different dates

Answer

You can use CASE EXPRESSION :

SELECT CASE WHEN t.first > t.second THEN 'Two different dates'
            ELSE 'In the same date'
       END as your_ind
FROM YourTable
Comments