Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.
  • Root
  • » Django
  • » Can I store full dates (mmddyyyy) and year-only dates (yyyy) in the same field? [RSS Feed]

#1 Jan. 25, 2011 17:17:13

Tim S.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

Can I store full dates (mmddyyyy) and year-only dates (yyyy) in the same field?


Hi Karen,

I did with two fields - storing a date and a date resolution.

The values could be:

date / resolution - display value

1984-12-31 / Exact Date - 31st December 1984
1984-12-01 / Month - December 1984
1984-01-01 / Year - 1984

So I just used the first of the month where unknown, and January where
unknown.

I then had a method on the model object to return the format based on the
stored date and the resolution.

It worked for what I needed it for,

Tim.

> Hello,
>
> I'm designing a model which is a collection of texts. Some of the
> texts will be things like books, with a YYYY date of publication, and
> some of them will be articles or transcripts with a mmddyyy date of
> publication/broadcast.
>
> I'd like to structure it somehow so that when I view the list of texts
> in the admin site, I see something like this:
>
>
> Title Date ...other
> fields
> ----------------------------------------------------------------------------------
> Sample Book 1984 ...
> Sample Blog Post 1/14/2010 ...
>
>
> Can I (should I?) store these two kinds of dates in one field? If I
> can't (or shouldn't), is there some other way to accomplish this
> (that's not too complicated)?
>
> Thanks,
> Karen
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> 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 django-users@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
  • » Can I store full dates (mmddyyyy) and year-only dates (yyyy) in the same field? [RSS Feed]

Board footer

Moderator control

Enjoy the 20th of October
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