Skip to content
Advertisement

Date of last day of week in Firebird 3

This is a date of first day of week (monday) in Firebird 3:

And how to get the date of the last day of the week (Sunday)?

In Firebird: Mon = 1, Tues = 2, … Sun = 0.

Advertisement

Answer

For ISO-8601 weeks, where Monday is the first day of the week, you can also determine Monday using:

The use of mod(extract(weekdays from d) + 6, 7) will make Monday 0, Tuesday 1, etc and Sunday 6 to make the calculations easier.

You can then determine Sunday using:

You can easily derive other days of the week this way (eg use 1 - mod(extract(weekday FROM d) + 6, 7) for Tuesday, etc.

On the other hand, if Sunday is the first day of the week (eg as in the US), you can use:

and for Monday

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement