Need to edge out the competition for your dream job? Train for certifications today.
ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.
One of a set of tools we're offering as a way to say thank you for being a part of the community.
declare @X int
declare @A date
declare @B varchar(10)
SET @B='DEC 31';
SELECT * FROM a
WHERE dateadd(year,@X,dob) Between @A AND convert(date, @B + ' ' + convert ( varchar(4),DATEPART(YEAR,@A)));
Open in new window
DOB >= DATEADD(YEAR, -21, @start_date) AND
DOB < DATEADD(DAY, 1, DATEADD(YEAR, -21, @end_date)) --I always use < rather than <=
--when dealing with date/datetime, so I add an extra day
the best practice with date and time ranges is to avoid BETWEEN and to always use the form:
WHERE col >= '20120101' AND col < '20120201'
This form works with all types and all precisions, regardless of whether the time part is applicable.
SELECT * FROM tbl
WHERE fld BETWEEN 10 AND 1
WHERE (((dt) Between #1/1/2016# And #1/1/2012#));
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
Please enter a first name
Please enter a last name
Must be at least 4 characters long.
Join and Comment
Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.