Re: [SQL] current_date / datetime stuff

2007-06-06 Thread Kristo Kaiv
true, didn't test it that thoroughly: mod 7 should be bit more beautiful select date_trunc('month',now()) + ( ((8 - extract('dow' from date_trunc('month',now()))%7) ||'days')::text)::interval; On 06.06.2007, at 18:54, Osvaldo Rosario Kussama wrote: Kristo Kaiv escreveu: oneliner: select da

Re: [SQL] current_date / datetime stuff

2007-06-06 Thread Osvaldo Rosario Kussama
Kristo Kaiv escreveu: oneliner: select date_trunc('month',now()) + ((8 - extract('dow' from date_trunc('month',now()))||'days')::text)::interval; There is a problem when first monday is 1st or 2nd day of month. bdteste=# SELECT date_trunc('month',meses) + ((8 - extract('dow' from date_t

Re: [SQL] current_date / datetime stuff

2007-06-05 Thread Rodrigo De León
On 6/5/07, Gerardo Herzig <[EMAIL PROTECTED]> wrote: We should have a onliner contest. I love oneliners!!! +1 on that ---(end of broadcast)--- TIP 6: explain analyze is your friend

Re: [SQL] current_date / datetime stuff

2007-06-05 Thread Gerardo Herzig
We should have a onliner contest. I love oneliners!!! oneliner: select date_trunc('month',now()) + ((8 - extract('dow' from date_trunc ('month',now()))||'days')::text)::interval; Kristo On 04.06.2007, at 19:39, Michael Glaesemann wrote: ---(end of broadcast)--

Re: [SQL] current_date / datetime stuff

2007-06-04 Thread Kristo Kaiv
oneliner: select date_trunc('month',now()) + ((8 - extract('dow' from date_trunc ('month',now()))||'days')::text)::interval; Kristo On 04.06.2007, at 19:39, Michael Glaesemann wrote: On Jun 4, 2007, at 10:59 , Michael Glaesemann wrote: On Jun 4, 2007, at 10:27 , Andrew Sullivan wrote:

Re: [SQL] current_date / datetime stuff

2007-06-04 Thread Michael Glaesemann
On Jun 4, 2007, at 10:59 , Michael Glaesemann wrote: On Jun 4, 2007, at 10:27 , Andrew Sullivan wrote: On Mon, Jun 04, 2007 at 10:04:37AM -0500, Joshua wrote: that will return the date of the first Monday of the month? I guess you need to write a function to do this. I suppose you could

Re: [SQL] current_date / datetime stuff

2007-06-04 Thread Rodrigo De León
On 6/4/07, Joshua <[EMAIL PROTECTED]> wrote: Hello, I was hoping someone here may be able to help me out with this one: Is there anything similiar to: SELECT current_date; that will return the date of the first Monday of the month? Please let me know. Thanks, Joshua select ( select ca

Re: [SQL] current_date / datetime stuff

2007-06-04 Thread Michael Glaesemann
On Jun 4, 2007, at 10:27 , Andrew Sullivan wrote: On Mon, Jun 04, 2007 at 10:04:37AM -0500, Joshua wrote: that will return the date of the first Monday of the month? I guess you need to write a function to do this. I suppose you could do it by finding out what day of the week it is and what

Re: [SQL] current_date / datetime stuff

2007-06-04 Thread Andrew Sullivan
On Mon, Jun 04, 2007 at 10:04:37AM -0500, Joshua wrote: > that will return the date of the first Monday of the month? I guess you need to write a function to do this. I suppose you could do it by finding out what day of the week it is and what the date is, then counting backwards to the earliest

[SQL] current_date / datetime stuff

2007-06-04 Thread Joshua
Hello, I was hoping someone here may be able to help me out with this one: Is there anything similiar to: SELECT current_date; that will return the date of the first Monday of the month? Please let me know. Thanks, Joshua ---(end of broadcast)--