isweekend

Tests whether datetime values fall on a Saturday or Sunday.

Category: Language Fundamentals > Data Types

Syntax

tf = isweekend(t)

Returns a logical array that is true for dates on a Saturday or Sunday.

Description

The test uses the calendar day only; the time of day does not matter. It treats Saturday and Sunday as the weekend regardless of locale.

Input arguments

t
datetime array.

Output arguments

tf
Logical array the same size as t.

Example

Friday to Sunday

t = datetime(2024,1,5) + days(0:2)
isweekend(t)
Output
t = 1×3 datetime array

   05-Jan-2024   06-Jan-2024   07-Jan-2024
ans = 1×3 logical array

   0   1   1

See also

weekday datetime isbetween day