I just watched such an example which shows how to get all cols by date here it is…
DECLARE @MyGetDate DATETIME
SELECT @MyGetDate = '2 Mar 2003 21:40'
SELECT *
FROM @Table
WHERE convert(varchar, @MyGetDate, 14) BETWEEN convert(varchar, startDate, 14) AND convert(varchar, endDate, 14)
… but the thing is I was trying to modify it as to get values within past 50 minutes. Here it is
SELECT value, my_date_col
FROM myTable
WHERE convert(varchar, my_date_col, 14) BETWEEN convert(varchar, dateadd(minute, -50, getdate()), 14) AND convert(varchar, getdate(), 14)
But it doesn’t work 🙁 So my question is how to use col my_date_col in such kind of statement?
Any useful comment is appreciated
I assume your
my_date_colis DateTime column, then you don’t need the casting. Casting is needed because the sample uses string representation of dates.