Re: [GENERAL] Date for a week day of a month

2007-07-04 Thread hubert depesz lubaczewski
On 7/3/07, Emi Lu [EMAIL PROTECTED] wrote: Can I know how to get the date of each month's last Thursday please? Query: select getDateBaseOnWeekday('2007-04-01', 'Last Thursday'); Result: 2007-04-26 you can easily do it without functions. for example, this select: SELECT cast(d.date + i *

Re: [GENERAL] Date for a week day of a month

2007-07-04 Thread Emi Lu
generate_series that's a good one! Thank you! On 7/3/07, Emi Lu [EMAIL PROTECTED] wrote: Can I know how to get the date of each month's last Thursday please? Query: select getDateBaseOnWeekday('2007-04-01', 'Last Thursday'); Result: 2007-04-26 you can easily do it without functions. for

[GENERAL] Date for a week day of a month

2007-07-03 Thread Emi Lu
Hello, Can I know how to get the date of each month's last Thursday please? For example, something like Query: select getDateBaseOnWeekday('2007-04-01', 'Last Thursday'); Result: 2007-04-26 Thank you! ---(end of broadcast)--- TIP 1: if

Re: [GENERAL] Date for a week day of a month

2007-07-03 Thread A. Kretschmer
am Tue, dem 03.07.2007, um 14:27:24 -0400 mailte Emi Lu folgendes: Hello, Can I know how to get the date of each month's last Thursday please? For example, something like Query: select getDateBaseOnWeekday('2007-04-01', 'Last Thursday'); Result: 2007-04-26 Write you own function. You

Re: [GENERAL] Date for a week day of a month

2007-07-03 Thread Nick Barr
Emi Lu wrote: Hello, Can I know how to get the date of each month's last Thursday please? For example, something like Query: select getDateBaseOnWeekday('2007-04-01', 'Last Thursday'); Result: 2007-04-26 Thank you! CREATE OR REPLACE FUNCTION lastday (date,int) RETURNS DATE AS ' DECLARE

Re: [GENERAL] Date for a week day of a month

2007-07-03 Thread Michael Glaesemann
On Jul 3, 2007, at 13:27 , Emi Lu wrote: Can I know how to get the date of each month's last Thursday please? For example, something like Query: select getDateBaseOnWeekday('2007-04-01', 'Last Thursday'); Result: 2007-04-26 Using a function for calculating the first occurrence of a

Re: [GENERAL] Date for a week day of a month

2007-07-03 Thread Emi Lu
Thank you all for your inputs! Based on your inputs, made it a bit change to my application: == DROP FUNCTION test_db.lastWeekdayDate (date, varchar) ; CREATE OR REPLACE FUNCTION test_db.lastWeekdayDate

Re: [GENERAL] Date for a week day of a month

2007-07-03 Thread Nick Barr
Emi Lu wrote: Hello, Can I know how to get the date of each month's last Thursday please? For example, something like Query: select getDateBaseOnWeekday('2007-04-01', 'Last Thursday'); Result: 2007-04-26 Thank you! It turns out my original solution was slightly (badly) wrong and was

Re: [GENERAL] Date for a week day of a month

2007-07-03 Thread Michael Glaesemann
On Jul 3, 2007, at 14:54 , Emi Lu wrote: result := ( (date_part('year', $1) || '-' || date_part('month', $1) || '-01')::date + '1 month'::interval - '1 day'::interval )::date; I recommend not using string manipulation to handle data that