Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » Extracting days,months,years from datefield. [RSS Feed]

#1 Dec. 31, 2010 11:53:12

Malte B.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Extracting days,months,years from datefield.


I got a models.DateField and would like to extract months and years from
that field so I can do calculations like a 'day in month' in a 'for month in
months' loop in a 'for year in years' loop. How can I extract that info from
a datefield? I have tried to read code written by others but their solutions
are not very obvious to me.

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

#2 Dec. 31, 2010 12:12:02

James B.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Extracting days,months,years from datefield.


On Fri, Dec 31, 2010 at 5:53 AM, Malte Beckmann
<monolithca...@googlemail.com> wrote:
> I got a models.DateField and would like to extract months and years from
> that field so I can do calculations like a 'day in month' in a 'for month in
> months' loop in a 'for year in years' loop. How can I extract that info from
> a datefield? I have tried to read code written by others but their solutions
> are not very obvious to me.

The value of a Datefield is a Python datetime.date object. To see the
attributes of datetime.date instances, which include what you want
here, see the Python datetime documentation:http://docs.python.org/library/datetime.html#date-objects--
"Bureaucrat Conrad, you are technically correct -- the best kind of correct."

--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en.

Offline

  • Root
  • » Django
  • » Extracting days,months,years from datefield. [RSS Feed]

Board footer

Moderator control

Enjoy the 18th of August
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support