saintadjie
saintadjie

Reputation: 46

how to show date, with daterange (2 dates) in sql

I have daterange

startdate : 2018-02-20
enddate : 2018-02-28

so i want to show date between startdate and enddate but exclude weekends (saturday and sunday)

the result should:

2018-02-20
2018-02-21
2018-02-22
2018-02-23
2018-02-26
2018-02-27
2018-02-28

how could i get the result with sql phpmyadmin?

thanks

Upvotes: 0

Views: 39

Answers (2)

vinieth
vinieth

Reputation: 1314

select * from tableName 
where dateColumn between 'startdate'and 'enddate'
and weekday(dateColumn) not in (5,6)

Upvotes: 1

Ari Singh
Ari Singh

Reputation: 1306

select * from tableName
where dateColumn > startdate 
and dateColumn < enddate
and weekday(dateColumn) in (0, 1, 2, 3, 4)

Upvotes: 0

Related Questions