→ Having trouble accessing our new support portal or creating a ticket? Please notify our team here

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Anthony_TMEIC
Engaged Sweeper II
Trying to generate a report to show PCs expiring/expired between two set dates (company fiscal year). What is the SQL code for specifying a date range?
1 ACCEPTED SOLUTION
RCorbeil
Honored Sweeper II
MSDN: BETWEEN
test_expression [ NOT ] BETWEEN begin_expression AND end_expression

So, for instance,
warranty_date BETWEEN '2015-01-01' AND '2015-12-31'

Alternatively, you can do the two comparisons explicitly, so
warranty_date >= '2015-01-01' AND warranty_date < '2016-01-01'

(I prefer the latter so that I see exactly what I'm asking for. A lot of the date/time fields I need to check include times and I want to be absolutely sure that the end-compare covers through 23:59:59.999 or whatever resolution the data type supports.)

View solution in original post

1 REPLY 1
RCorbeil
Honored Sweeper II
MSDN: BETWEEN
test_expression [ NOT ] BETWEEN begin_expression AND end_expression

So, for instance,
warranty_date BETWEEN '2015-01-01' AND '2015-12-31'

Alternatively, you can do the two comparisons explicitly, so
warranty_date >= '2015-01-01' AND warranty_date < '2016-01-01'

(I prefer the latter so that I see exactly what I'm asking for. A lot of the date/time fields I need to check include times and I want to be absolutely sure that the end-compare covers through 23:59:59.999 or whatever resolution the data type supports.)