Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

django annotate datetime field to char

from django.db.models import F, Func, Value, CharField

qs.annotate(
  formatted_date=Func(
    F('created_at'),
    Value('DD-MM-YYYY HH:MM:SS'),
    function='to_char',
    output_field=CharField()
  )
)
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #django #annotate #datetime #field #char
ADD COMMENT
Topic
Name
7+3 =