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

Mista Gomez you are right... one shouldn't mess with the db for time issues :-)

I found out about a convenient way to calculate i.e. the 4 Monday of this or next month:

set datenow                            [clock scan now]
set first_day_of_month                  [clock scan [clock format $datenow -format %Y]-[clock format $datenow -format %m]-01]
set first_day_of_month_fmt              [clock format $first_day_of_month -format "%Y-%m-%d"]
set first_day_of_next_month            [clock scan "1 month" -base [clock scan $first_day_of_month_fmt]]
set first_day_of_next_month_fmt        [clock format $first_day_of_next_month -format "%Y-%m-%d"]

set n_day_of_n_week_of_month            [clock scan "Monday 3 Week" -base [clock scan "$first_day_of_month_fmt"]]
set n_day_of_n_week_of_month_fmt        [clock format $n_day_of_n_week_of_month -format "%Y-%m-%d"]
set n_day_of_n_week_of_next_month      [clock scan "Monday 3 Week" -base [clock scan "$first_day_of_next_month_fmt"]]
set n_day_of_n_week_of_next_month_fmt  [clock format $n_day_of_n_week_of_next_month -format "%Y-%m-%d"]

Thanks for posting this. I'll see where in acs-events, calendar, datetime "select from sysdate" is being used and will deprecate and/or supersede the respective procs.