terasfen.blogg.se

Minus minutes in sql
Minus minutes in sql








minus minutes in sql

minus minutes in sql

Where DATEDIFF(minute,time, getdate()) between 720 AND 840

minus minutes in sql

Where DATEDIFF(minute,time, getdate()) between 600 AND 720 Where DATEDIFF(minute,time, getdate()) between 480 AND 600 Where DATEDIFF(minute,time, getdate()) between 360 AND 480 Where DATEDIFF(minute,time, getdate()) between 240 AND 360 Where DATEDIFF(minute,time, getdate()) between 120 AND 240 Where DATEDIFF(minute,time, getdate()) <= by time desc The below covers me for the 24 hour period required. I think I have cracked it, might be overcomplicating things but the below seems to work, pending further testing. Im new to T-SQL so I might be completely wrong in my approach.

Minus minutes in sql how to#

This is why I want to find out how to GETDATE() then minus X amount of minutes. In my second example I only want to display between 07:00 and 09:00 SO in my first example I only want to display between 09:00 and 11:00 I don’t want to show ALL entries only the oldest 2 hours (120 minutes) Assuming the time is 13:00 and the variable is 240 (4Hours) I would expect all rows from v_myview to be returned between 09:00 and 13:00 – which it does.ĭATEDIFF(mi, time, getdate()) < by time descĪnother example: Assuming the time is 13:00 and the variable is 360 (6 Hours) I would expect all rows from v_myview to be returned between 07:00 and 13:00. for example, I would expect this query to return the following. The following sql is my procedure, an application passes through the variable which is in minutes. Im struggling to explain this so I will try again What is your expected result from running that? The actual result is shown below, but what do you want to display? So, check this outįROM Datediff(mi, TIME, Getdate()) <= BY TIME DESCįROM Dateadd(mi, -120, Getdate()) <= BY TIME DESCįROM Dateadd(mi, -240, Getdate()) <= BY TIME DESCįROM Dateadd(mi, -360, Getdate()) <= BY TIME DESC I can't quite understand what you want here.










Minus minutes in sql