Calculate next event date based on instance of the day of week

From: Dimitri <a(dot)dmitri(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: Calculate next event date based on instance of the day of week
Date: 2010-12-02 21:46:44
Message-ID: AANLkTinmnh-keYONR6y+9g5k3a3BSMDTXH-mB2mjGO8T@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

I'm sure the subject sounds extremely confusing :)

I have a table which stores an event date. The event is stored as a
standard mm/dd/yy entry.

I then need to calculate based on the dd value, WHICH day of the week that
is (e.g. Wednesday) and which occurrence of that day of the week, within the
month, it is (e.g. the THIRD Wednesday).

From there, I need to calculate, based on the previously obtained
information, the mm/dd/yy DATE of next month's third Wednesday.

My business analyst has attempted a few various solutions but we seem to
keep missing the mark, we've found tons of information for how to do it in a
MySQL or MSSQL instance, but none on Postgres, or at least, none that have
worked.

Any help would be appreciated, thanks!

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Jayadevan M 2010-12-03 06:17:28 Re: Calculate next event date based on instance of the day of week
Previous Message Humair Mohammed 2010-12-02 21:45:21 COPY with FORMAT in Postgresql 9.x