Click here to Skip to main content
15,914,416 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi friend
i have column dateofbirth(dob)
the date is saving 8/11/1958 format in this columns i want to create search the user can pick the age from two dropdownlist like 18 between 25 and so on. in store procedure
plz solutions
Posted
Comments
Om Prakash Pant 9-Jul-12 9:04am    
so you only want the age and not date of birth?
Sebastian T Xavier 9-Jul-12 9:10am    
whats the issue?
Sandeep Mewara 9-Jul-12 9:28am    
And what is the issue?
You got the date, you got the design, go ahead and write related query/code for it.
[no name] 9-Jul-12 10:00am    
"plz solutions"... is that the name of your company?
I am guessing that you want permission to write the query? Well then, you have my permission.

Hi ,
Check this
you will send like number 25 and you will pass it as -25 so you will get the date of birth for this age and then you will make your Query
SQL
declare @Prev int
set @Prev = -25
declare @EndDate datetime
select @EndDate =( SELECT DATEADD(year,@Prev, GETDATE()))
select @EndDate

select * from TableName where ColDate between GETDATE() and @EndDate

Best Regards
M.Mitwalli
 
Share this answer
 
SQL
CREATE PROCEDURE getDetailsAgeWise 
	@FirstAge int,
	@SecondAge int
AS
BEGIN
	declare @FirstDate datetime,@SecondDate datetime
	set @Firstage=0-@Firstage
	set @Secondage=0-@SecondAge
	set @Firstdate=(select dateadd(year,@Firstage,getdate()))
	set @SecondDate=(select dateadd(year,@Secondage,getdate()))
 
select * from TableName where ColDob between @SecondDate and @Firstdate

 
END


It may be your proper store procedure
 
Share this answer
 
Comments
Mohamed Mitwalli 10-Jul-12 1:16am    
5+

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900