![]() If that doesn't help you, then I'm afraid I just don't understand your question. I believe Attempt 2 gives you what you need. SELECT DATEDIFF(d, Value1, Value2), įROM Attempt 2: Date diff taking it down to the minutes level INSERT INTO (Value1, Value2, ) VALUES (' 12:00', ' 12:01', '48 hours 1 min') Output: The difference in minutes is: 21 minutes We can also find the time difference in minutes using the following method.See the sample code below, and compare the outputs: DECLARE TABLE(Value1 SMALLDATETIME, Value2 SMALLDATETIME, NVARCHAR(50)) The way around this is to go down to a more granular level, such as minutes instead of days. I think the issue you may be having is to do with rounding in SQL's DATEDIFF function. just substitute StartDate and EndDate for your column names, and tableName for the actual table name.Īlso, you can swap out the 'd' character for other dateparts, say if you wanted to find the date difference in months, years etc. Something like: SELECT DATEDIFF(d, StartDate, EndDate) FROM tableName ![]() ![]() If you're talking about SQL Server, DATEDIFF is what you need. ![]()
0 Comments
Leave a Reply. |