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 |
Rayman
Starting Member
39 Posts |
Posted - 2010-11-09 : 16:59:27
|
I read the earlier post to see if someone had address this topic.I have a column with the following data:birth_date4/23/19458/20/19623/27/19622/11/19583/21/195111/18/19518/15/19832/22/19711/24/193111/14/194412/15/194910/15/19659/25/1967I need to read this and produce the following information:day_born/ageMonday / 41.7Wednsday/ 58.2Saturday/ 78.4Tuesday / 51.3Sunday / 57.6Thursday/ 59.5Monday / 64.1Friday / 43.6Tuesday / 64.6I placed the forward slash in the represent the space between the data and column.But I need to calculate the date and extract the day of the week and the yearsTerry Lynn King |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
Rayman
Starting Member
39 Posts |
Posted - 2010-11-10 : 12:36:19
|
SELECT person_name, birth_city, dayname(birth_date) as day_born,truncate(datediff(current_date,birth_date)/ 365,1) as age, operations FROM `john` ORDER by person_nameThe query is hanging on the dayname function. Is there a better way to do this? I reviewed the Microsoft SQL server transact-SQL and utilities reference, Vol 2. I am just missing a simple syntax issue.The error states dayname not a recognize function. I change to Day and get the same thing.Terry Lynn King |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
Rayman
Starting Member
39 Posts |
Posted - 2010-11-10 : 13:00:01
|
Microsoft SQL 2005 on Windows 2003 server.Terry Lynn King |
|
|
TimSman
Posting Yak Master
127 Posts |
Posted - 2010-11-10 : 13:05:28
|
There is no DayName function. Unless you wrote it.And why do you have TRUNCATE in there? I would get rid of that, too. |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-11-11 : 04:58:30
|
TRUNCATE is an ORACLE function. Also there is no reason to use it on the numbers as datediff will return integersMadhivananFailing to plan is Planning to fail |
|
|
|
|
|