
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2015 04:57 PM
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?
Solved! Go to Solution.
Labels:
- Labels:
-
Report Center
1 ACCEPTED SOLUTION
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2015 07:54 PM
MSDN: BETWEEN
So, for instance,
Alternatively, you can do the two comparisons explicitly, so
(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.)
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.)
1 REPLY 1
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-29-2015 07:54 PM
MSDN: BETWEEN
So, for instance,
Alternatively, you can do the two comparisons explicitly, so
(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.)
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.)
