How do I get the start and end dates of the week in Postgres? (week starts from Monday)

Source: Internet
Author: User

             select extract (ISOYEAR  from fromdate_)  as year_,     --the year in which the week was made extract (WEEK FROM  fromdate_)  as week_,        --the year in which the week was made To_char (fromDate _ , ' YYYYMMDD ')  as fromdate_,  --Week start date to_char (todate_ , ' YYYYMMDD ')  as  End date of todate_       --week from   (select  (date  (curDate)  - 7* weeks_)       as fromDate_,           (date  (curdate)  - 7* weeks_ + 6 )  as  toDate_ from  ( select generate_series (1,100)  weeks_,          --  interval weeks (sequence, here take 100 weeks) cast (Date_trunc (' Week ',  current_date)  as  character varying)  as curdate --  the first day of the week on which the current date is located      )  as fg 




How do I get the start and end dates of the week in Postgres? (week starts from Monday)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.