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)
 retrieving day of the week

Author  Topic 

dirwin26
Yak Posting Veteran

81 Posts

Posted - 2008-05-12 : 11:10:57
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

30421 Posts

Posted - 2008-05-12 : 11:12:40
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 - 2008-05-12 : 11:19:40
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

52326 Posts

Posted - 2008-05-12 : 11:24:47
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 - 2008-05-12 : 11:27:48
'DAYOFWEEK' is not a recognized datename option.
Go to Top of Page

dirwin26
Yak Posting Veteran

81 Posts

Posted - 2008-05-12 : 11:31:32
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

30421 Posts

Posted - 2008-05-12 : 11:40:32
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

30421 Posts

Posted - 2008-05-12 : 11:41:54
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 - 2008-05-12 : 16:02:48
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
   

- Advertisement -