August 17, 2007 at 1:27 pm
I would like to calculate dates to return number of years and number of day's to look like this
i.e 30 Years and 21 Days = Don't ask why it's how the work it.
I would like to check for an joindate and calculate the number of date's to today
It's just stumping me
let's say the table looks like this
cst_id----joindate-----expire date----terminate_Date
I don't want to use a function case I only need it one time.
Thanks in advance.
August 17, 2007 at 3:04 pm
declare
@date smalldatetime,
@days int
set @date = '07/16/1998'
select
@days = datediff(dd, @date, getdate())
cast(cast(@days/365.25 as int) as varchar(2)) + ' years and ' + cast(cast(round(@days % 365.25,0) as int) as varchar(3)) + ' days.'
August 18, 2007 at 2:55 am
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply