Hi,
Running SQL Server 2008 R2. I have the following sample table:
CREATE TABLE [dbo].[Test]
(
[Test_ID] [int] NOT NULL,
[Start_Time] [char](5) NULL,
[End_Time] [char](5) NULL,
[Elapsed_Time] [char](5) NULL,
CONSTRAINT
[PK_Test_Test_ID] PRIMARY KEY CLUSTERED ([Test_ID] ASC)
WITH
(
PAD_INDEX = OFF,
STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON
)
ON [PRIMARY]
)
ON [PRIMARY]
GO
Start and End Times are stored in 'hh:nn' format.
How could I use T-SQL to calculate the elapsed time between [Start_Time] and [End_Time], stored in 'hh:nn' format? [Elapsed_Time] will never exceed 24:00 but there may be occasions where [Start_Time] could be 23:45 and [End_Time] could be 00:05. Under these conditions [Elapsed_Time] would need to be 00:20.
Thanks in advance for any assistance!