Forum OpenACS Q&A: Re: how to find out the exact date of i.e. "1st monday of this month"

I'm too lazy to try the commands myself but it's something like...

set datenow [clock scan [date]]
set first_day_of_month "[clock scan [clock format $datenow -format %Y]-[clock format $datenow -format %m]-01]"
set day_of_year [clock format $first_day_of_month -format %j]
set day_of_week_of_first_day [clock format $first_day_of_month -format %w]

So you'll now have the day of year of the first day of the current month as well as it's day of week. Sunday is 0.

With those two values, a couple or so [expr]'s should get you the first monday.

Also possible using a similar approach in sql.