Hello,
I need a bit of help with a a datediff statement. I would like to
replace the year portion of a static month and day in the statement with
the year portion of a getdate().
My code looks like this
Datediff("d" [birthday], 11/30/2004) / 365.24
This give the age, which I would like to then use this to report the
grade of the student.
Basically if a student age is between the nov and nov they are grouped
together in the same grade.
Thanks in advance
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!Assuming birthday is a datetime, this may work for you...
select dateadd(yy,datediff(yy,@.birthday,getdate
()),@.birthday)
"1idesigned" <code@.1idesigned.com> wrote in message
news:OtgJJ1UBEHA.3776@.tk2msftngp13.phx.gbl...
> Hello,
> I need a bit of help with a a datediff statement. I would like to
> replace the year portion of a static month and day in the statement with
> the year portion of a getdate().
> My code looks like this
> Datediff("d" [birthday], 11/30/2004) / 365.24
> This give the age, which I would like to then use this to report the
> grade of the student.
> Basically if a student age is between the nov and nov they are grouped
> together in the same grade.
> Thanks in advance
>
>
> *** Sent via Developersdex http://www.examnotes.net ***
> Don't just participate in USENET...get rewarded for it!|||Thanks for the reply, someone suggested some that looks like this that I
am using,
DECLARE @.MyDate As varchar(10)
SET @.mydate = '11/30/' + cast(year(getdate())as varchar)
SELECT 'GradeLevel' =
CASE
WHEN DateDiff("d", birthdate, @.mydate) /365.25 <9.999 THEN 'Less than
3th Grade'
WHEN DateDiff("d", birthdate, @.mydate) /365.25 >8.999 and
DateDiff("d", birthdate, @.mydate) /365.25 <9.999 THEN '03th Grader'
This allows me not to change the 11/30/yy date.
Thanks
*** Sent via Developersdex http://www.examnotes.net ***
Don't just participate in USENET...get rewarded for it!
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment