I have a table containing the following columns
| TrailerID | ScheduleDate | ActualDate | AcutalCube |
I would like to pull the trailerID if the day of the week is, say Tuesday. I have found I can get the day of the week for a specific row using datepart, however I would like to pull all rows for a given day of the week. I have tried the following
select * from summary where datepart(dw, ' ') = '5'. (the name of the table is "summary".)
The query executes successfully with 0 rows. The results of the query are to be pulled into C# and then put into a structure for further manipulation. If I can avoid pulling all of the rows in sql then altering it in C# to only those I want that would be wonderful.
Javeed M ShaikhPosted Oct 10, 2011, 9:02 PM
Shouldn't the second parameter of the datepart be your date column, like this:
select * from summary where datepart(dw,datecolumntoselect)='5';
Also note that Sunday = 1, Saturday = 7; so in your case Thursday=5.
Please do not forget to mark "Accepted Answer".
Javeed M ShaikhPosted Oct 10, 2011, 10:13 PM
Rodney JohnsonPosted Oct 10, 2011, 9:17 PM
Thanks