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.
| Author |
Topic |
|
h2sut
Starting Member
40 Posts |
Posted - 2010-05-05 : 23:03:50
|
| I have a question is there a way i can convert 17.5 to be 17 years and 6 months? Not sure if there a way to do it |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-05-05 : 23:46:10
|
| If this is for presentation then i suggest you do it in front end..Regards,BohraI am here to learn from Masters and help new bees in learning. |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-05-06 : 13:14:58
|
just do likeSELECT FLOOR(number) AS years,number-FLOOR(number) * 12 AS monthsFROM Table ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2010-05-06 : 13:23:20
|
| [code]SELECT FLOOR(17.5) AS years,(17.5-FLOOR(17.5)) * 12 AS months [/code]http://weblogs.sqlteam.com/jeffs/archive/2008/05/13/question-needed-not-answer.aspxHow to ask: http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxFor ultra basic questions, follow these links.http://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
h2sut
Starting Member
40 Posts |
Posted - 2010-05-07 : 16:25:44
|
I really appreciate the help. This worked. I was trying to % and getting issues. Thanks again for your help.quote: Originally posted by visakh16 just do likeSELECT FLOOR(number) AS years,number-FLOOR(number) * 12 AS monthsFROM Table ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/
|
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-05-08 : 06:04:38
|
| welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Tks
Starting Member
48 Posts |
Posted - 2010-05-08 : 08:56:48
|
| I would convert the field in de table to datetime. In every language there is a way to calculate the difference and store it as a datetime.In that way you can just do select year(datetimecolumn) as Years, month(datetimecolumns) as months etc... |
 |
|
|
|
|
|