Category / Section
How to exclude weekend from date column in Bold BI?
Published:
In this article, we will learn how to exclude weekend (Saturdays and Sundays) from a date column using an expression.
Steps to Exclude Weekends from a Date Column:
1. Use the following expression to exclude Sundays and Saturdays from the date column:
SQL Server:
IF(DATENAME(WEEKDAY, [BirthDate]) = 'Sunday' OR DATENAME(WEEKDAY, [BirthDate]) = 'Saturday', NULL, [BirthDate])
MySQL, PostgreSQL:
IF(DATENAME(day, [BirthDate]) = 'Sunday' OR DATENAME(day, [BirthDate]) = 'Saturday', NULL, [BirthDate])
Replace [BirthDate] with the name of your date column.
2. The resulting date field will not have weekend days (Saturdays and Sundays).
We can apply the same expression to remove any day from the date column, by specifying the day name.
Related Articles: