Friday, March 23, 2012

how to find year from 1900 to 2000 using store procedure in sql server

hi friends
i want to know how to calculate year ranging from 1900 to 2000 using store procedure in sql serveroh, that's easy :)

which year?|||What exactly you want to do?|||create procedure CalculateYearBetween1900And2000(@.InputDate datetime)
as
begin
declare @.OutputYear int
if year(@.InputDate) between 1900 and 2000
set @.OutputYear = year(@.InputDate)
select @.OutputYear
end|||Do you want a random year? Are the day and month important too, or just the year?

-PatP|||...
if year(@.InputDate) between 1900 and 1000
...
i don't see this returning TRUE very often...|||dbforums did not take my original edit. the code has been corrected and should work fine now.|||ah, i understand

it was one of those edits that disappeared down the same hole that many archived threads have gone...|||Have you used a select statement for simplicity or would you simply not consider an OUTPUT variable or RETURN year(@.InputDate)?

No comments:

Post a Comment