Re: query date by string

2010-12-03 Thread owidjaya
so you are saying that SELECT * FROM some_table WHERE some_date LIKE "2010%" is not possible? On Dec 3, 9:30 am, bruno desthuilliers wrote: > On 3 déc, 17:37, owidjaya wrote: > > > in php I can run the following query for mysql > > > SELECT * FROM some_table WHERE some_date LIKE "2010%" > > > H

Re: query date by string

2010-12-03 Thread bruno desthuilliers
On 3 déc, 17:37, owidjaya wrote: > in php I can run the following query for mysql > > SELECT * FROM some_table WHERE some_date LIKE "2010%" > > How do i do this in django using cursor.execute()? sql = "SELECT * FROM some_table WHERE YEAR(some_date)=%s" cursor.execute(sql, (2010,)) -- You receiv

Re: query date by string

2010-12-03 Thread wayne
On Dec 3, 11:13 am, oscar widjaya wrote: > It's for mysql > it still does not work. I tried it with the following sql statement > "SELECT * FROM project_project WHERE start_date LIKE '%s'" % '2010%%' Well, I assume that the double % at the end of your query is unintentional, as I don't think it

Re: query date by string

2010-12-03 Thread owidjaya
It's for mysql it still does not work. I tried it with the following sql statement "SELECT * FROM project_project WHERE start_date LIKE '%s'" % '2010%%' On Dec 3, 9:04 am, wayne wrote: > On Dec 3, 10:47 am, owidjaya wrote: > > > It says incorrect date value. > > What database are you using?  I'm

Re: query date by string

2010-12-03 Thread oscar widjaya
It's for mysql it still does not work. I tried it with the following sql statement "SELECT * FROM project_project WHERE start_date LIKE '%s'" % '2010%%' On Fri, Dec 3, 2010 at 9:04 AM, wayne wrote: > > > On Dec 3, 10:47 am, owidjaya wrote: > > It says incorrect date value. > > > > What databas

Re: query date by string

2010-12-03 Thread wayne
On Dec 3, 10:47 am, owidjaya wrote: > It says incorrect date value. > What database are you using? I'm wondering if this is an issue of formatting the sql correctly. Did you read the snippet near the bottom of the page I linked to? Try: SELECT * FROM some_table WHERE some_date LIKE "%s" % '

Re: query date by string

2010-12-03 Thread owidjaya
It says incorrect date value. On Dec 3, 8:44 am, wayne wrote: > You should be able to do it just as you mention, passing the query > string to cursor.execute(). > > Seehttp://docs.djangoproject.com/en/dev/topics/db/sql/#executing-custom-... > > Have you tried this?  Are you getting an error?  If

Re: query date by string

2010-12-03 Thread wayne
You should be able to do it just as you mention, passing the query string to cursor.execute(). See http://docs.djangoproject.com/en/dev/topics/db/sql/#executing-custom-sql-directly Have you tried this? Are you getting an error? If so, what is it? -- You received this message because you are

query date by string

2010-12-03 Thread owidjaya
in php I can run the following query for mysql SELECT * FROM some_table WHERE some_date LIKE "2010%" How do i do this in django using cursor.execute()? -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django