[sqlalchemy] Re: query date field
--On 6. Juli 2007 23:27:30 + jose [EMAIL PROTECTED] wrote: I've got a question that I can't find the answer to. I have a table called seminars with a date field in it to hold the seminar dates. I want to query the table to find all the dates for a specific year. I tried query(Seminars).filter(Seminars.c.date.year==2007) but this gave me an error stating that the col does not have a year property. So how should I do this? Jose func.to_char(table.c.date, '') == '2007' or by using between(table.c.date, datetime(2007,1,1) , datetime(2007,31, 12)) or something like that... -aj pgpML11WJE8sW.pgp Description: PGP signature
[sqlalchemy] Re: query date field
On 7/6/07, Andreas Jung [EMAIL PROTECTED] wrote: --On 6. Juli 2007 23:27:30 + jose [EMAIL PROTECTED] wrote: I've got a question that I can't find the answer to. I have a table called seminars with a date field in it to hold the seminar dates. I want to query the table to find all the dates for a specific year. I tried query(Seminars).filter(Seminars.c.date.year==2007) but this gave me an error stating that the col does not have a year property. So how should I do this? Jose func.to_char(table.c.date, '') == '2007' or by using between(table.c.date, datetime(2007,1,1) , datetime(2007,31, 12)) or something like that... Or func.year(table.c.date) == 2007 -- Mike Orr [EMAIL PROTECTED] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: query date field
heh...youve both answered correctly ...based on the databases you happen to be using (oracle, mysql). unfortanately we dont yet have a layer of function abstraction that smooths over differences like these. theres a ticket in place in trac but its awaiting a volunteer for now. On Jul 7, 5:03 am, Mike Orr [EMAIL PROTECTED] wrote: On 7/6/07, Andreas Jung [EMAIL PROTECTED] wrote: --On 6. Juli 2007 23:27:30 + jose [EMAIL PROTECTED] wrote: I've got a question that I can't find the answer to. I have a table called seminars with a date field in it to hold the seminar dates. I want to query the table to find all the dates for a specific year. I tried query(Seminars).filter(Seminars.c.date.year==2007) but this gave me an error stating that the col does not have a year property. So how should I do this? Jose func.to_char(table.c.date, '') == '2007' or by using between(table.c.date, datetime(2007,1,1) , datetime(2007,31, 12)) or something like that... Or func.year(table.c.date) == 2007 -- Mike Orr [EMAIL PROTECTED] --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---
[sqlalchemy] Re: query date field
Thanks, everyone for the pointers. Since func is not database agnostic, I think I'll make my own functions in my database module that simply use func so if I ever do switch form mysql to something else at least I'll know where to find all the stuff that needs changing Jose jose wrote: I've got a question that I can't find the answer to. I have a table called seminars with a date field in it to hold the seminar dates. I want to query the table to find all the dates for a specific year. I tried query(Seminars).filter(Seminars.c.date.year==2007) but this gave me an error stating that the col does not have a year property. So how should I do this? Jose --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups sqlalchemy group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~--~~~~--~~--~--~---