This question already has answers here:
Get records 10 min before system datetime in SQL
(4 answers)
Closed 6 years ago.
How can I substract the column "begin_execution" with 5 minutes?
The begin_execution-Datetime will filled via an SQL-Task, but i need this time -5 minutes to check the running compatibility.
Example:
SELECT * FROM queue_entry WHERE begin_execution - GETDATE()-5min AND STATUS = 'not solved'
Thats the original output:
2016-06-09 15:00:11.4070000
i need this output (-5 minutes):
2016-06-09 14:55:11.4070000
WHERE begin_execution >= DATEADD(MINUTE, -5, GETDATE())
Related
This question already has answers here:
PostgreSQL Age Calculation from date type
(2 answers)
Closed 3 years ago.
I want to select all participants who are not 18 years old, but using the current date how do I do this.
I would not like to use the following way,
SELECT * FROM participants WHERE data_of_birth < '2020-01-01';
Does anyone know otherwise?
It can be solved with an interval:
SELECT * FROM participants WHERE data_of_birth > (current_date - '18 years'::interval)::date;
This question already has an answer here:
SQL Server Management Studio make default date 5 days from now
(1 answer)
Closed 4 years ago.
I need to create a view everyday with all records reaching the "Prazo" date ('Prazo' stands for due date in Portuguese), so everyday I need to make a select showing all the records that are 5 days from reaching the due date. How can I do that?
You can do:
Select *
from Table as t
Where DATEDIFF(DD, GETDATE(), PrazoDate) = 5
It just says how many records from today are 5 days from reaching their due date.
This question already has answers here:
how to remove time from datetime
(10 answers)
What is the best way to truncate a date in SQL Server?
(6 answers)
Closed 8 years ago.
I'm using the following query to get the maximum days in a month as a datetime.
Select DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,'2014-01-01')+1,0))
The query result is: 2014-01-31 23:59:59.000
How can I get the following result : 2014-01-31 00:00:00.000
Thanks,
This question already has answers here:
SQL: Get records created in time range for specific dates
(3 answers)
Closed 8 years ago.
I have a table with the field ENTERED_ON (with both date and time value). I want to write a query that return records that have ENTERED_ON value that is past 2 hours comparing to current date time.
For example, if entered_on is 2014-05-06 11:00AM, and currently it's 2014-05-06 2:00PM, I would like to return all records that past the 2 hours when comparing to current date time.
You can write query using INTERVAL. It will looks like
SELECT * FROM Table WHERE `ENTERED_ON` > DATE_ADD(NOW(), INTERVAL -2 HOUR)
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
Specific Time Range Query in SQL Server
For example I have 3 rows:
Id Date
1 '2011-01-02 09:14:23.0000000'
2 '2011-02-15 10:15:47.0000000'
3 '2011-03-18 21:12:33.0000000'
And I whant to take only rows, where TIME between 09:00 and 11:00 and any date.
I need this in result set:
Id Date
1 '2011-01-02 09:14:23.0000000'
2 '2011-02-15 10:15:47.0000000'
Thanks
Here's one approach
SELECT id, date
FROM myTable
WHERE CONVERT(VARCHAR(8),Date,108) between '09:00:00' and '11:00:00'