Hi Galil,

In the next version of Django (1.10) you'll be able to use the TruncDate 
expression[1]
for this exact purpose:

MyModel.objects.annotate(join_date=TruncDate('join_time')).values_list('join_date',
 
flat=True)

In the mean time you can simply use a Func expression[2]:

MyModel.objects.annotate(join_date=Func(F('join_time'), 
function='DATE')).values_list('join_date', flat=True)

Cheers,
Simon

[1] 
https://docs.djangoproject.com/en/1.10/ref/models/database-functions/#django.db.models.functions.datetime.TruncDate
[2] 
https://docs.djangoproject.com/en/1.9/ref/models/expressions/#func-expressions

Le mardi 14 juin 2016 09:52:34 UTC-4, Galil a écrit :
>
> Hi, 
>
> How can I convert this SQL query into a Django query?
>
> SELECT DATE(JoinTime) FROM table
>
> Please keep in mind that JoinTime is in datetime format and I want it to 
> be date.
>
> Thanks
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4d8fd591-b3b1-4222-a065-c416e2f72110%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to