Re: Code for getting particular day of week number from month

2018-12-12 Thread Andrew Gierth
> "Mike" == Mike Martin writes: Mike> Hi Mike> For a particular sequence I needed to do (schedule 2nd monday in Mike> month for coming year) I created the following query That doesn't look like the best way - you're generating and discarding a lot of rows. "second monday in month X" can

Fwd: Code for getting particular day of week number from month

2018-12-11 Thread Francisco Olarte
On Tue, Dec 11, 2018 at 2:10 PM Mike Martin wrote: > For a particular sequence I needed to do (schedule 2nd monday in month for > coming year) I created the following query nice, but a little brute force. Is this what you are trying to do: $ select d::date as month_starts, to_char(date_tr

Code for getting particular day of week number from month

2018-12-11 Thread Mike Martin
Hi For a particular sequence I needed to do (schedule 2nd monday in month for coming year) I created the following query select to_char(min(date::date) + interval '1 week','DD/MM/') date --gets first date for day of month (monday in this case) then adds week and finally formats it to desi