Re: Lookup by week
I don't know the Django API very well, however it might make sense to support the date extraction functions offered by various databases. I have to admit that I only use Oracle and Sql Server at work, however I know that they support month, day, year, day of week, day of year, week number datepart extractions. It seems to me that i've done it in Postgresql as well, though I only use pgsql for personal projects. Personally I often have to have things organized by week number, usually for reporting purposes. At least then if someone wants "fortnight", it's easier to explain why the API doesn't handle it (because databases don't support that datepart).On 1/31/06, Max Battcher <[EMAIL PROTECTED]> wrote: Adrian Holovaty wrote:> On 1/30/06, Jan Rademaker <[EMAIL PROTECTED]> wrote:>> Would it make sense to implement such a thing? An alternative would be >> to figure out at what date a week starts and ends and just use>> pub_date__range, but that's not really the point. I'm just curious how>> easy/hard it would be to implement.>> >> If the above isn't going to work, what's the best/most elegant way to>> go, __range?>> Yeah, I'd suggest calculating the week start/end dates in your own> code and using the __range lookup. Weeks are a bit of a messy problem > -- different people have different definitions of when they start,> etc.Then, if weeks are implemented, you start to get requests for fortnightsand scores...Max Battcher-- http://www.worldmaker.net/
Re: Lookup by week
On 1/31/06, Jamison Roberts <[EMAIL PROTECTED]> wrote: > I don't know the Django API very well, however it might make sense to > support the date extraction functions offered by various databases. -1. As an app developer, I don't want to think about which DB supports which date parts. I already have mxDate to deal with all that stuff. I think Adrian's right: do some app-level thing (perhaps using a good library), and just feed django dates.
Re: Lookup by week
Adrian Holovaty wrote: On 1/30/06, Jan Rademaker <[EMAIL PROTECTED]> wrote: Would it make sense to implement such a thing? An alternative would be to figure out at what date a week starts and ends and just use pub_date__range, but that's not really the point. I'm just curious how easy/hard it would be to implement. If the above isn't going to work, what's the best/most elegant way to go, __range? Yeah, I'd suggest calculating the week start/end dates in your own code and using the __range lookup. Weeks are a bit of a messy problem -- different people have different definitions of when they start, etc. Then, if weeks are implemented, you start to get requests for fortnights and scores... -- --Max Battcher-- http://www.worldmaker.net/
Re: Lookup by week
On 1/30/06, Jan Rademaker <[EMAIL PROTECTED]> wrote: > Would it make sense to implement such a thing? An alternative would be > to figure out at what date a week starts and ends and just use > pub_date__range, but that's not really the point. I'm just curious how > easy/hard it would be to implement. > > If the above isn't going to work, what's the best/most elegant way to > go, __range? Yeah, I'd suggest calculating the week start/end dates in your own code and using the __range lookup. Weeks are a bit of a messy problem -- different people have different definitions of when they start, etc. Adrian -- Adrian Holovaty holovaty.com | djangoproject.com | chicagocrime.org
Lookup by week
Hello, As far is I know it's not possible to query date fields for a cerain week number, eg. # Select all polls from week 5, 2006 polls.get_list( pub_date__year=2006, pub_date__week=5 ) Would it make sense to implement such a thing? An alternative would be to figure out at what date a week starts and ends and just use pub_date__range, but that's not really the point. I'm just curious how easy/hard it would be to implement. If the above isn't going to work, what's the best/most elegant way to go, __range? - janr