-3

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.

Dale K
  • 25,246
  • 15
  • 42
  • 71
Abhi
  • 21
  • 3

3 Answers3

0

I hope this can help:

SELECT *
FROM [YourTableName] t
WHERE DATENAME(WEEKDAY,t.[YourDateField]) NOT IN ('Saturday','Sunday');
Dale K
  • 25,246
  • 15
  • 42
  • 71
Vitaly Borisov
  • 1,133
  • 2
  • 13
  • 20
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,743
  • 3
  • 20
  • 27
-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.

Dale K
  • 25,246
  • 15
  • 42
  • 71
Jisha GJ
  • 29
  • 7