Getting start time from a datetime range in SQL Server

Using the base strings functions we can try:

SELECT
    Date,
    LEFT(Date, CHARINDEX(' ', Date) - 1) AS Date,
    SUBSTRING(Date,
              CHARINDEX(' ', Date) + 1,
              CHARINDEX(' ', Date, CHARINDEX('-', Date) + 1) -
                  CHARINDEX(' ', Date) - 3) AS Time
FROM yourTable;

screen capture from demo link below

Demo

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top