Specific times of the day

  • I'd like to query data between 7:30am and 4pm, 4pm and midnight, and then midnight and 7:30am without regard to the actual date.

    I have no idea how to accomplish this. Any help will be GREATLY appreciated.

  • SELECTSUM(CASE WHEN CONVERT(CHAR(8), Col1, 114) >= '07:30:00' AND CONVERT(CHAR(8), Col1, 114) < '16:00:00' THEN 1 ELSE 0 END) AS [7:30am to 4pm],

    SUM(CASE WHEN CONVERT(CHAR(8), Col1, 114) >= '16:00:00' AND CONVERT(CHAR(8), Col1, 114) < '24:00:00' THEN 1 ELSE 0 END) AS [4pm to 12pm],

    SUM(CASE WHEN CONVERT(CHAR(8), Col1, 114) >= '00:00:00' AND CONVERT(CHAR(8), Col1, 114) < '07:30:00' THEN 1 ELSE 0 END) AS [12pm to 7:30am]

    FROMTable1


    N 56°04'39.16"
    E 12°55'05.25"

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply