Week numbers and calculating weekly statistics/diagrams - Mailing list pgsql-general

From Alexander Farber
Subject Week numbers and calculating weekly statistics/diagrams
Date
Msg-id 943abd911002160414y1949b13apa0a29eecfbd62fc3@mail.gmail.com
Whole thread Raw
Responses Re: Week numbers and calculating weekly statistics/diagrams  (Martijn van Oosterhout <kleptog@svana.org>)
Re: Week numbers and calculating weekly statistics/diagrams  (Greg Smith <greg@2ndquadrant.com>)
Re: Week numbers and calculating weekly statistics/diagrams  (Thom Brown <thombrown@gmail.com>)
List pgsql-general
Hello,

I have multiplayer card game in Flash/Perl/C and would
like to add weekly tournaments/player ratings to it.

This means I have to add a table which holds:
player id, weekly score (which I update after each round)
and the week number.

Does anybody has an advice how to save the week number?

If I save it as a timestamp then calculating realtime statistics
(on a player profile click) will probably be CPU-intensive,
because I have to calculate the week numbers each time.

If I save it as string "2010/52" then it's difficult to show
statistics for a period of time (like for the last 12 months)
if there is a new year inbetween.

Maybe there is a better way?

I'm using postgresql-server-8.3.6 and OpenBSD 4.5

Regards
Alex

pgsql-general by date:

Previous
From: Peter Geoghegan
Date:
Subject: Re: Having a plpgsql function return multiple rows that indicate its progress in a cursor like fashion
Next
From: Alban Hertroys
Date:
Subject: Re: Having a plpgsql function return multiple rows that indicate its progress in a cursor like fashion