pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Brian C. Doyle <bcdoyle@mindspring.com>
To: jmckown@prodigy.net
Cc: pgsql-sql@postgresql.org
Subject: Re: Week of the Year?
Date: Sun, 03 Sep 2000 07:25:23 -0400
Message-ID: <4.3.2.7.2.20000903072517.00c90b00@pop> (raw)

John,

Would you have any clue how to figure out the first saturday of any month - 
6 days and the last saturday of that month?

I know that this seems odd but i have to run reports for "Non Standard 
Months" and well I am clueless.

At 09:55 PM 8/11/00 -0500, you wrote:

>Try using the function date_part such as:
>
>select date_part('week',now());
>
>"and the days that are in that week" I guess want to answer a question
>such as:
>Given a date, what is first date in that same week, and what is the last
>date in that week. There are a couple of approaches to this. My first was:
>
>select
>to_date(date_part('year',now()),'YYYY')+(7*date_part('week',now()));
>
>and the above +6 to the the last day of the week. Another approach for
>this same question is much simplier (if the question is indeed what you
>are asking)
>
>select now()-date_part('dow',now());
>
>This last select gives the Sunday for the current week. To get the
>Saturday, simply:
>
>select now()-date_part('dow',now())+6;
>
>Of course, replace the now() with whatever contains the date or timestamp.
>
>John McKown
>
> > I'm probably staring right at it. (One of the difficulties with RTFMing, is
> > having too many docs!)
> >
> > Is there anything in the API that produces the week of the year, from 1 to
> > 52 or 53 depending on the week of the year, and the days that are in that
> > week?
> >
> > Many thanks.
> >
> >                                           -dlj.
> >
> >
> >




view thread (6+ messages)  latest in thread

Message-ID: <4.3.2.7.2.20000903072517.00c90b00@pop>
Permalink:  ../4.3.2.7.2.20000903072517.00c90b00@pop/
Also on:    postgresql.org/message-id/4.3.2.7.2.20000903072517.00c90b00@pop

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: bcdoyle@mindspring.com, jmckown@prodigy.net
  Subject: Re: Week of the Year?
  In-Reply-To: <4.3.2.7.2.20000903072517.00c90b00@pop>
  References: <4.3.2.7.2.20000903072517.00c90b00@pop>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox