[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

date_trunc(week,timestamp) not working in postgresql 7

Posted on 2006-11-01
2
Medium Priority
?
1,142 Views
Last Modified: 2008-02-01
The following query

select  date_trunc(week,timestamp)

retrieves the start_date of the current week as timestamp ,

2006-10-10 00:00:00

It works in postgresql 8. But fails in postgresql 7.
Let me know the postgresql query which retrieves first date of a week (compatible in both postgresql 7 and 8 versions)
0
Comment
Question by:shathy
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Author Comment

by:shathy
ID: 17848878
The following query

select  date_trunc(week,timestamp)

retrieves the start_date of the current week as timestamp ,

2006-10-10 00:00:00

It works in postgresql 8. But fails in postgresql 7.
Let me know the postgresql query which retrieves first date of a week (compatible in both postgresql 7 and 8 versions)
0
 
LVL 22

Accepted Solution

by:
earth man2 earned 2000 total points
ID: 17862041
=> select current_timestamp::date - ( 5 + to_number( to_char( current_timestamp, 'D' ),'9' )::int ) % 7;
  ?column?  
------------
 2006-10-30
(1 row)
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many developers have database experience, but are new to PostgreSQL. It has some truly inspiring capabilities. I have several years' experience with Microsoft's SQL Server. When I began working with MySQL, I wanted a quick-reference to MySQL (htt…
By, Vadim Tkachenko. In this article we’ll look at ClickHouse on its one year anniversary.
Steps to create a PostgreSQL RDS instance in the Amazon cloud. We will cover some of the default settings and show how to connect to the instance once it is up and running.
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question