|
-
calculate birthdate
I need to figure out who will be turning age 65 in april, may, or june, 2004.
What should be the code, does anyopne know?
Thanks.
-
select * from DOBTable where DOB >='04/01/'+convert(varchar(4),year(getdate())-65)
and DOB<='06/30/'+convert(varchar(4),year(getdate())-65)
-
Hi Mak, it didn't work...
-
do u have a table with "Date of Birth" as column?
select '04/01/'+convert(varchar(4),year(getdate())-65)
--results 04/01/1939
select '06/30/'+convert(varchar(4),year(getdate())-65)
--results 06/30/1939
--basically my query is doing the following
select * from DOBTable where DOB >='04/01/1939'
and DOB<='06/30/1939'
-
Yes I do, but my dob field is defined as char length of 8 and the data is in format 19850102 (year,month,date).
Thx.
-
select convert(datetime,convert(varchar(4),year(getdate() )-65)+ '0401',112)
--1939-04-01 00:00:00.000
select convert(datetime,convert(varchar(4),year(getdate() )-65)+'0630',112)
--1939-06-30 00:00:00.000
select * from DOBTable where DOB >=convert(datetime,convert(varchar(4),year(getdate ())-65)+ '0401',112)
and DOB<=convert(datetime,convert(varchar(4),year(getd ate())-65)+'0630',112)
-
Thank you soooooooooo much, that worked.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|