SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 retrieving day of the week
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

dirwin26
Yak Posting Veteran

81 Posts

Posted - 05/12/2008 :  11:10:57  Show Profile  Reply with Quote
I am trying to look at a datetime date and am setting the column next to it to the corresponding day of the week. Instead I am getting the associated number of the month

DayofWeek Datecolumn
NULL 2007-12-13

I want Dayofweek to be tuesday, or whatever the right day is for 12-13
I'm using the below but I am getting the answer 13....not tuesday. I thought datename was for returning strings?

Update TAble
set DayOfWeek = datename (day, DateColumn)

SwePeso
Patron Saint of Lost Yaks

Sweden
29910 Posts

Posted - 05/12/2008 :  11:12:40  Show Profile  Visit SwePeso's Homepage  Reply with Quote
SELECT DATENAME(DAYOFWEEK, DateColumn)



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

dirwin26
Yak Posting Veteran

81 Posts

Posted - 05/12/2008 :  11:19:40  Show Profile  Reply with Quote
I tried putting it into an update statement and I still get the day of the month in number form, not day of the week as in tuesday. Any ideas on what's up?

update table
set dayofweek= (select datename(day, datecolumn))
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52249 Posts

Posted - 05/12/2008 :  11:24:47  Show Profile  Reply with Quote
quote:
Originally posted by dirwin26

I tried putting it into an update statement and I still get the day of the month in number form, not day of the week as in tuesday. Any ideas on what's up?

update table
set dayofweek= (select datename(day, datecolumn))



DO you think you used the solution you were provided with?
Go to Top of Page

dirwin26
Yak Posting Veteran

81 Posts

Posted - 05/12/2008 :  11:27:48  Show Profile  Reply with Quote
'DAYOFWEEK' is not a recognized datename option.
Go to Top of Page

dirwin26
Yak Posting Veteran

81 Posts

Posted - 05/12/2008 :  11:31:32  Show Profile  Reply with Quote
and as you know a select statement can't be used in an update unless you embed it in parenthases, unless there is something else I don't know.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
29910 Posts

Posted - 05/12/2008 :  11:40:32  Show Profile  Visit SwePeso's Homepage  Reply with Quote
SELECT DATENAME(WEEKDAY, DateColumn)

This is very easy so lookup in Books Online, btw.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

Sweden
29910 Posts

Posted - 05/12/2008 :  11:41:54  Show Profile  Visit SwePeso's Homepage  Reply with Quote
quote:
Originally posted by dirwin26

and as you know a select statement can't be used in an update unless you embed it in parenthases, unless there is something else I don't know.

I can spoon-feed you too


UPDATE Table
SET DayOfWeek = DATENAME(WEEKDAY, DateColumn)



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

cat_jesus
Aged Yak Warrior

547 Posts

Posted - 05/12/2008 :  16:02:48  Show Profile  Reply with Quote
quote:
Originally posted by dirwin26

and as you know a select statement can't be used in an update unless you embed it in parenthases, unless there is something else I don't know.




Something else you don't know? Impossible!





An infinite universe is the ultimate cartesian product.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000