Quantcast
Channel: ฟอรัม Getting started with SQL Server
Viewing all articles
Browse latest Browse all 8428

Time Arithmetic

$
0
0

I have a column named [DateAdded]

I am trying to find all records posted in the last hour.

I thought putting the following WHERE clause would work

SELECT 
	T1.[FAXID],
	T1.[FilePathTIF],
	T2.[DateAdded]
FROM 
	FaxQueueFiles as T1
INNER JOIN  
	FaxQueue as T2
ON 
	T1.[FaxID] = T2.[FaxID]
WHERE 
	GETDATE() - T2.[DateAdded] >= 60;

It does not produce the results I want. Can anyone help me on what I am doing wrong? Even if I change >= to <= it does not give me only the records in the last hour. Should it not be 60?

The [DateAdded] column is of format YYYY-MM-DD HH:MM:SS:MS

It seems that 60 represents days. So to get the last hour, would it be >= (1/24) ?


-Nothing to see. Move along.



Viewing all articles
Browse latest Browse all 8428

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>