A table with 7 rows having all weekdays as value. I just want a simple sql query to get all the values from the weekdays except weekends.
Asked
Active
Viewed 356 times
-4
-
2What have you tried so far? – Russ J Mar 21 '19 at 03:31
-
And what does your database look like? How are the values stored? Strings, Integers, etc – Reed Mar 21 '19 at 04:53
3 Answers
0
I hope this can help:
SELECT *
FROM [YourTableName] t
WHERE DATENAME(WEEKDAY,t.[YourDateField]) NOT IN ('Saturday','Sunday');
Dale K
- 21,987
- 13
- 41
- 69
Vitaly Borisov
- 1,081
- 1
- 13
- 19
0
Simple, Try this :
SELECT *
FROM [YourTable]
WHERE DATENAME(WEEKDAY,[DateField]) <> 'Saturday'
AND DATENAME(WEEKDAY,[DateField]) <> 'Sunday'
There is a Similar question with solutions.
Sabir Al Fateh
- 1,625
- 2
- 18
- 26
-1
MySQL WEEKDAY() function returns the index of the day in a week for a given date (0 for Monday, 1 for Tuesday through to 6 for Sunday).
Syntax:
WEEKDAY(date) Where date is a date.