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
 Transact-SQL (2000)
 From days to years, months, days

Author  Topic 

seth666
Starting Member

2 Posts

Posted - 2006-03-09 : 05:16:19
I have data in table in days. I need to convert it to years, months days...sample:

6868 days -> ?years, ?months, ?days

Thank you...


...And justice for all

Kristen
Test

22859 Posts

Posted - 2006-03-09 : 05:48:14
Hi seth666, Welcome to SQL Team!

Depends on Leap Years doesn't it?

And if you start from 1st January you'll get a different number of months than if you start from 1st February!!

Kristen
Go to Top of Page

seth666
Starting Member

2 Posts

Posted - 2006-03-09 : 07:01:20
Yes I know. I need this for calculating peoples working years. I have all data in days....Any Idea?


...And justice for all
Go to Top of Page

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2006-03-09 : 07:23:42
if you don't have a start date you're in trouble...
i guess you could do something like if weekends aren't counted in days number:
6668/5 = w = how many weeks
w/52 = y = years

this is of course far from accurate...

Go with the flow & have fun! Else fight the flow
Go to Top of Page

RickD
Slow But Sure Yak Herding Master

3608 Posts

Posted - 2006-03-09 : 07:45:50
Is it how many days worked or how many days since they started?

If it's how many day since they started, you could do:


dateadd(dd,-6868,getdate())


to get their start date..
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-03-09 : 08:12:45
This may give you some more ideas
http://sqlteam.com/forums/topic.asp?TOPIC_ID=62729

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -