Depends on the DBMS you use.
If you are SQL Server, use the function DATEPART. I will leave it to you to read the documentation on the link. The form would be as follows:
WHERE DATEPART(p.dtvenc, 'weekday') BETWEEN 2 AND 6
Where 2
and Monday and 6
it’s Friday.
If it is Oracle, you refer to the form of the function to_char
that receives a date.
WHERE to_char(p.dtvenc, 'D') in ('2', '3', '4', '5', '6')
Editing: The @Caffé called attention to the fact that the number corresponding to each day of the week in Oracle may vary. This depends on the language/culture set up. For more details (if you are curious or have problems with the numbers), I suggest searching for National Language Support (the link that Caffé commented).
If it is Mysql, Postgresql or other system... In this case you expect someone who knows them to answer here. Tag the bank you use in the question helps you get better answers.
Try to keep the code on the questions reduced to the minimum necessary for your understanding, okay? The original code was immense and most had nothing to do with the problem.
– Oralista de Sistemas
Actually, Wesley, this has to do with this topic from the help center: How to create a Minimum, Complete and Verifiable example, but the ideal would be for you to do this and not an editor.
– brasofilo
OK, I’ll follow the advice!!! Thank you
– Wesley Costa