I'm focusing on a credit card applicatoin the shops time values inside a database e.g Expected duration of Arrival and actual duration of arrival. What's the easiest way of storing these fields inside a database?
What SQL query can one use to get the time distinction between the 2 fields?
If you are on SQL Server 2008, make use of the
TIME datatype. Declare individuals two fields
ExpectedTimeOfArrival TIME(7), ActualTimeOfArrival TIME(7)
Educate yourself regarding how to manipulate time datatype here.
After you have individuals two fields in position, you could include a calculated column for your table that computes the main difference between individuals two, e.g. within a few minutes:
ALTER TABLE dbo.YourTable ADD TimeDifference AS DATEDIFF(MINUTE, ActualTimeOfArrival, ExpectedTimeOfArrival)
and you could query o that new column
TimeDifference as though it were an ordinary, regular table column.