Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 One more for tonight :)

Author  Topic 

keithc1
Yak Posting Veteran

88 Posts

Posted - 2004-06-11 : 00:59:37
Hey I seen this in a profile here
and person has this code to tell there age I beleive. What is the number "22211.0028" referring to?


Select Datediff(dd,convert(datetime,22211.0028),Getdate())/365.00 As Years




Keithc MCSE MCSA

timmy
Master Smack Fu Yak Hacker

1242 Posts

Posted - 2004-06-11 : 01:08:43
Their birth date, if you convert the date to a decimal

1960-10-24 00:04:01.917
Go to Top of Page

keithc1
Yak Posting Veteran

88 Posts

Posted - 2004-06-11 : 08:53:46
Tim how would you do the conversion?
I been trying with convert function but so far no luck. I keep getting

Error converting data type varchar to numeric.

Keithc MCSE MCSA
Go to Top of Page

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2004-06-11 : 08:56:26
declare @dob as datetime
set @dob = '1960-10-24 00:04:01.917'

select cast(@dob as decimal(18, 4))


Duane.
Go to Top of Page

keithc1
Yak Posting Veteran

88 Posts

Posted - 2004-06-11 : 09:15:50
Awesome!!!Thanks a bunch ditch

Keithc MCSE MCSA
Go to Top of Page

ditch
Master Smack Fu Yak Hacker

1466 Posts

Posted - 2004-06-11 : 09:31:15
This can also be done without using variables:

select cast(CAST('1960-10-24 00:04:01.917' as datetime) as decimal(18, 4))


Duane.
Go to Top of Page
   

- Advertisement -