I have a bit of a problem replacing the week() method from mysql in some of my queries. The equivalent function for week($date) would be "extract week from $date". All good until I found a mysql query where the week function is called with the second parameter like this: select week(date,3). Based on mysql site, second parameter means that : "Week 1 is the first week with more than 3 days this year(for second parameter=3)". I made a couple of tests with some dates on both mysql and postgresql and noticed that "select week(date,3)" and extract(week from date) sometime returns different values. Anyone has any ideea for a workaround on this issue??

Thanks

Search Discussions

  • Greg Sabino Mullane at Nov 18, 2010 at 3:16 pm

    select week(date,3). Based on mysql site, second parameter means that
    "Week 1 is the first week with more than 3 days this year(for second parameter=3)"
    There is nothing directly compatible in Postgres: we only deal with
    the ISO 8601 standard of a week. You would need to write your own
    function to emulate it completely. It might be worth checking some
    of the mysql compatibility projects to see if someone has already
    done so.

    - --
    Greg Sabino Mullane greg@turnstep.com
    End Point Corporation http://www.endpoint.com/
    PGP Key: 0x14964AC8 201011181015
    http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouppgsql-novice @
categoriespostgresql
postedNov 18, '10 at 1:08p
activeNov 18, '10 at 3:16p
posts2
users2
websitepostgresql.org
irc#postgresql

People

Translate

site design / logo © 2022 Grokbase