Datetime variables TSQL

Syntax for a TSQL date time variable

DECLARE @START_DATE DATETIME
DECLARE @END_DATE DATETIME

SET @START_DATE = '09/21/2012 00:00:00'
SET @END_DATE = '09/21/2012 23:59:59'

SELECT * FROM TABLE WHERE POSTINGDATE >= @START_DATE and POSTINGDATE <= @END_DATE

Leave a Reply