views:

42

answers:

1

I'm doing a web application for articles
Articles must be shown by month, with its published date stored as mm/yyyy

Now:

1- Should I use a DATE type field for storing?
2- Will jQuery UI datePicker be useful for showing mm/yyyy?
3- How could I sort by mm/yyyy?

I guess it will be more complicated if I store date normally and extract the day from date each time I want to do something, right?

Thanks,

+1  A: 

I would store the published date as a DateTime value in my database and then do something different for the display. With the DatePicker's you can set the format for how the date should be presented.

$( "MyDate" ).datepicker( { altFormat: 'mm/yyyy' } );

If your articles are always Month and Year and the actual day doesn't matter, you may want to think about usability a bit. It may be better to use Drop Down Lists for the Months and Year...

RSolberg
Thanks RSolberg. I've thought about usability, but the mm/yyyy was a main request in the client's project
Enrique
@Enrique: What exactly does `mm/yyyy` give you vs `Month` `Year`? It functions the same way. It wouldn't make sense to use a datepicker that is designed to pick a "day" `dd` for something like selecting a month and year.
RSolberg