On Sat, Mar 10, 2007 at 00:03:04 -0300,
Jorge Godoy <[EMAIL PROTECTED]> wrote:
>
> If I run this query:
>
>select date_trunc('week', '2007-03-08'::date + 5);
>
> it fails even for that date. The correct answer, would be 2007-03-07 and not
> 2007-03-12. I want the first day of the week to
Omar Eljumaily <[EMAIL PROTECTED]> writes:
> But you're always returning Monday, right? Your grouping will be correct, but
> to get the actual truncation date, you have to subtract back.
>
> select (date_trunc('week', '2007-03-07'::date + 5)::date-5);
> select (date_trunc('week', '2007-03-06'::da
Bruno Wolff III <[EMAIL PROTECTED]> writes:
> On Fri, Mar 09, 2007 at 23:07:26 -0300,
> Jorge Godoy <[EMAIL PROTECTED]> wrote:
>>
>> But how to get the date if the first day of the week is a Wednesday? This
>> example is like the ones I've sent with separate queries that needed being
>> combin
But you're always returning Monday, right? Your grouping will be
correct, but to get the actual truncation date, you have to subtract back.
select (date_trunc('week', '2007-03-07'::date + 5)::date-5);
select (date_trunc('week', '2007-03-06'::date + 5)::date-5);
select (date_trunc('week', '2007-
On Fri, Mar 09, 2007 at 23:07:26 -0300,
Jorge Godoy <[EMAIL PROTECTED]> wrote:
>
> But how to get the date if the first day of the week is a Wednesday? This
> example is like the ones I've sent with separate queries that needed being
> combined -- in a function, probably -- to get the desired r
Bruno Wolff III <[EMAIL PROTECTED]> writes:
> On Fri, Mar 09, 2007 at 20:13:11 -0300,
> Jorge Godoy <[EMAIL PROTECTED]> wrote:
>> Bruno Wolff III <[EMAIL PROTECTED]> writes:
>>
>> > No, it has to be inside the function so that the modular arithmetic is
>> > applied to it.
>>
>> Then there's th
On Fri, Mar 09, 2007 at 20:13:11 -0300,
Jorge Godoy <[EMAIL PROTECTED]> wrote:
> Bruno Wolff III <[EMAIL PROTECTED]> writes:
>
> > No, it has to be inside the function so that the modular arithmetic is
> > applied to it.
>
> Then there's the error I've shown from your command. Can you give me
"Ted Byers" <[EMAIL PROTECTED]> writes:
> I don't buy the suggestion that server side code is less error prone that
> client side code, but be that as it may, we're talking about a function that
> has one line of code. And given what you just said, you don't want the day of
> the week, you want
Omar Eljumaily <[EMAIL PROTECTED]> writes:
> Ted, my reason for asking the question that I believe precipitated this thread
> was that I wanted a single sql statement that aggregated time data by week.
> Yes, I could do the aggregation subsequently in my own client side code, but
> it's easier and
"Ted Byers" <[EMAIL PROTECTED]> writes:
> Out of curiosity, why does the database need to know this, or to be able to
> calculate it? There are lots of things that would be useful to me, if the
It was a curiosity. But it would make working with some dates easier. I've
given some examples but i
Bruno Wolff III <[EMAIL PROTECTED]> writes:
> No, it has to be inside the function so that the modular arithmetic is
> applied to it.
Then there's the error I've shown from your command. Can you give me a
working one? This was with PostgreSQL 8.2.3.
--
Jorge Godoy <[EMAIL PROTECTED]>
--
- Original Message -
From: "Omar Eljumaily" <[EMAIL PROTECTED]>
To: "Ted Byers" <[EMAIL PROTECTED]>
Cc:
Sent: Friday, March 09, 2007 5:00 PM
Subject: Re: [GENERAL] Setting week starting day
Ted, my reason for asking the question that I believe prec
Ted, my reason for asking the question that I believe precipitated this
thread was that I wanted a single sql statement that aggregated time
data by week. Yes, I could do the aggregation subsequently in my own
client side code, but it's easier and less error prone to have it done
by the server
It is not hard to calculate, as you can see... but it would be nice if
"date_trunc('week', date)" could do that directly. Even if it became
"date_trunc('week', date, 4)" or "date_trunc('week', date, 'Wednesday')"
it
would be nice... :-) And that is what I was trying to ask ;-)
Use date_trun
On Fri, Mar 09, 2007 at 16:44:57 -0300,
Jorge Godoy <[EMAIL PROTECTED]> wrote:
> Bruno Wolff III <[EMAIL PROTECTED]> writes:
>
> > On Fri, Mar 09, 2007 at 14:59:35 -0300,
> > Jorge Godoy <[EMAIL PROTECTED]> wrote:
> >> It is not hard to calculate, as you can see... but it would be nice if
> >>
Bruno Wolff III <[EMAIL PROTECTED]> writes:
> On Fri, Mar 09, 2007 at 14:59:35 -0300,
> Jorge Godoy <[EMAIL PROTECTED]> wrote:
>> It is not hard to calculate, as you can see... but it would be nice if
>> "date_trunc('week', date)" could do that directly. Even if it became
>> "date_trunc('week',
On Fri, Mar 09, 2007 at 14:59:35 -0300,
Jorge Godoy <[EMAIL PROTECTED]> wrote:
> It is not hard to calculate, as you can see... but it would be nice if
> "date_trunc('week', date)" could do that directly. Even if it became
> "date_trunc('week', date, 4)" or "date_trunc('week', date, 'Wednesday')
Alvaro Herrera <[EMAIL PROTECTED]> writes:
> Jorge Godoy escribió:
>
>> Just to repeat my question:
>>
>> (I don't want to write a function, I can do that pretty easily... And I was
>> asking if there existed some feature on the database that... It's just a
>> curiosity)
>>
>> Given a date X
I think you can coax the date_trunc function to give you a proper start
day. I think it's more than adding an integer to your date, though.
You also have to do some mod work after the function returns, I think.
I agree that the point isn't that you can't do it with some effort,
however. It'
Jorge Godoy escribió:
> Just to repeat my question:
>
> (I don't want to write a function, I can do that pretty easily... And I was
> asking if there existed some feature on the database that... It's just a
> curiosity)
>
> Given a date X it would return me the first day of the week so that
Bruno Wolff III <[EMAIL PROTECTED]> writes:
> On Thu, Mar 08, 2007 at 20:32:22 -0300,
> Jorge Godoy <[EMAIL PROTECTED]> wrote:
>> Alvaro Herrera <[EMAIL PROTECTED]> writes:
>>
>> As I said, it is easy with a function. :-) I was just curious to see if we
>> had something like Oracle's NEXT_DAY
On Thu, Mar 08, 2007 at 20:32:22 -0300,
Jorge Godoy <[EMAIL PROTECTED]> wrote:
> Alvaro Herrera <[EMAIL PROTECTED]> writes:
>
> As I said, it is easy with a function. :-) I was just curious to see if we
> had something like Oracle's NEXT_DAY function or something like what I
> described (SET BO
Alvaro Herrera <[EMAIL PROTECTED]> writes:
> Jorge Godoy escribió:
>
>> I mean, if I wanted to do the above but instead of Sunday or Monday as the
>> starting day I'd like using Fridays or Wednesdays...
>>
>> Is it possible? Writing a new function shouldn't be too hard -- it's a
>> matter
>> of
23 matches
Mail list logo