Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Flexible Date of Birth Field 2

Status
Not open for further replies.

sonny1974

Technical User
Feb 25, 2007
161
US
I have a DOB field, but i want to make sure that it pulls any kids under 6

what would the formula be if i want to do that.

i want to make sure the current date changes daily so it doesnt need to be done manually
 
Approximately
Code:
DATEDIFF(YEAR, DOB, getdate()) < 6
Those who reach the sixth birthday later this year would be included.

Code:
DATEDIFF(MONTH, DOB, getdate()) < 6 * 12
Those who turn six later this month are included.

Code:
DATEDIFF(DAY, DOB, getdate()) < 6 * 365
Except leapyears might be off by a day.

 
Hi sonny1974, I just wanted to try and help out here before things go south for you.

First thing is this question really should have been answered from this question It doesn't give us much ambition to help if you post the same relevant question in separate threads in the same day ;-)

It's a very good idea to reply to threads you have started with a small thanks, it worked, I'm having problems and such. Also we're really not here to do your work for you. As direct and angry as that phrase sounds we're not. Once you've researched and tried things we're more than happy to get you through them but I'm hoping Tek-Tips is not looked upon as a code bank or code generating application. We want to help you get to the point things are understandable on your own to the point you can do this and most importantly, fix them when they break.

Also, there are some great FAQ's that will help you in posting and hey, if you want to give back replying to others.

This forum has some and just about every other forum has them.
faq183-5565
faq183-3179
faq183-874

Read them. They will help get us all doing our best to help you expand and strengthen your skills while you are tasked with these things.

Please note and I want to say it again. It is respectful and just common courtesy to give thanks to the members here that are taking time out of their own work days to help others in our community. Tek-Tips has the star system which as small as it may seem is a very good way to show your appreciation and to point out excellent and valuable posts.

Try it out. I did for rac2 because the post was very complete and covered things to keep you from having to find them out the hard way.

Have fun and happy programming

[sub]____________ signature below ______________
You may get help by means of code here. Just recall what happens to a rat when he eats the cheese off a rat trap while you're Ctrl+C/Ctrl+V'ing that code as your own[/sub]
 
Adding to rac2

Code:
--this will return the date 6 years ago
declare @Birth smalldatetime
set @Birth = dateadd(yy,-6,getdate())

--this will get you any kids younger than 6 to the day
select * from YOUR_TABLE
where DOB > @Birth

Well Done is better than well said
- Ben Franklin
 
ok onpnt,

i will do so. sorry about that, i will make sure i do my own research here before i ask the question.

thanks for the heads up before i get kicked off.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top