Hi Jagdeep,

Consider to use a query like this example:

sales =
Sale.objects.extra(select={'month':'month(date_created)','year':'year(date_created)'}).values('year','month').annotate(month=11,year=2010)

It works on mysql.

More information http://docs.djangoproject.com/en/dev/ref/models/querysets/

Cheers

Rogério Carrasqueira

---
e-mail: [email protected]
skype: rgcarrasqueira
MSN: [email protected]
ICQ: 50525616
Tel.: (11) 7805-0074



2010/11/22 Jagdeep Singh Malhi <[email protected]>

> Hi
> I have two Problems with Mysql Query
>
> First problem :
> for example :-
>
> >>>client = ClientJob.objects.filter(date__contains = '2010-11- ')
> >>> client
>
> Warning Message is :-
> Warning: Incorrect date value: '%2010-11-%' for column 'date' at row 1
>
> its doesn't work
> I want use Mysql Query like :-
> SELECT ... WHERE date LIKE '2010-11-%';
>
> Second Problem:
> I declayer two varables and want use in MySql Query
> for example :-
>
> def  function(request):
>        if request.method == 'POST':
>                form = MonthlyReport(request.POST)
>                if form.is_valid():
>                        cd = form.cleaned_data
>                        month = cd['month']
>                        year = cd['year']
>                        client = ClientJob.objects.filter(date__contains =
> year-month-__)
>
> I am using two  Variables year and month in query and got Syntax
> error or
> error:
> unsupported operand type(s) for -: 'unicode' and 'unicode'
>
> I want to use variables in Query.
>
> Please help
>
> Thanks
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<django-users%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to