Welcome, Guest
Username: Password: Remember me

TOPIC: Suggestions to deal with old and ancient dates

Suggestions to deal with old and ancient dates 11 Feb 2013 14:56 #6694

  • dieda1821
  • dieda1821's Avatar
  • Offline
  • Senior Member
  • Posts: 53
  • Thank you received: 2
  • Karma: 4
Hi,

I would like to be able to deal with old and ancient dates, that is: prior to 1902 (even if the server is 32-bit) and prior to 1000.

Although I know about the MySql DATE lower limit, I confirm what stated in this interesting post (last comment):

http://stackoverflow.com/questions/2487543/does-mysql-support-historical-date-like-1200]

The MySql documentation states that DATE can not store dates prior to 1000 (and with my component I can not go before 1902 since my local xampp is on a 32-bit system), but if I insert the date manually from PhpMyAdmin, I can store a date prior to 1000 and do not receive any error message: the correct value appears then in the front-end view, but not in the back-end (where it becomes 1901-12-31).

Do you have any suggestions about I could store dates before 1901 or even before 1000 from the component ?

Thanks

Elena
Last Edit: 11 Feb 2013 14:56 by dieda1821.
The administrator has disabled public write access.

Re: Suggestions to deal with old and ancient dates 11 Feb 2013 15:56 #6695

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
Hi Elena,

Yes, that is an interesting post!

Well, I agree that date formatted data will only be necessary if you are need to use the date in calculations. Moreover, as stated in the article, you're very unlikely to want to calculate the precise time in-between 2 ancient dates however, formatting it as a string would suffice - YYYY-MM-DD should do the trick - as ordering by the string will work fine.

Therefore I'd stick with a string data type and if necessary, provide a calendar widget on the input field.

If on the other hand, there are some more complex operations required, maybe you could save the day, month and year completely separately - each with integer data type. Then, use php date to glue it back together and operate with?

Hope it's at least a little bit helpful!

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.

Re: Suggestions to deal with old and ancient dates 11 Feb 2013 19:29 #6696

  • dieda1821
  • dieda1821's Avatar
  • Offline
  • Senior Member
  • Posts: 53
  • Thank you received: 2
  • Karma: 4
Thanks Gez.

I thought about the issue and after all I think the simpler solution is replacing my date field (at least those that could be very old) as string, eventually putting a constraint in the format.

I'm not sure if the datepicker would be helpful, since one should scroll the years a lot to pick up dates before, say, 1500 and, besides, prior to 1500 one should take care of all the adjustments to the calendars.

It's a pity that MySql put this limit, considering that through PhpMyAdmin this limit does not seem to exist :-)

Elena
The administrator has disabled public write access.

Re: Suggestions to deal with old and ancient dates 11 Feb 2013 19:55 #6697

  • JoomGuy
  • JoomGuy's Avatar
  • Offline
  • Moderator
  • Joomla Enthusiast, Lover of Cooking
  • Posts: 1115
  • Thank you received: 195
  • Karma: 64
No probs!

RE: datepicker, I didn't mean a calendar control like jQuery UI but more a day, month & year combo... That way, you could at least impose some decent front-end validation such as number of days in the month etc.

however you decide to do it, validating and sorting results with php will be straight-forward enough.

Yes, it is a bit of shame about SQL date handling but, that said, you're going to be handling most of your evaluation in the application layer in any case...

Hope it doesn't cause you too many hassles!

Gez
Need help with your Cook/Joomla Project? . PM me to find out what I can help with. NO time wasters please!!!
The administrator has disabled public write access.

Re: Suggestions to deal with old and ancient dates 18 Feb 2013 16:13 #6813

  • g1smd
  • g1smd's Avatar
  • Offline
  • Junior Member
  • RegEx fiend!
  • Posts: 31
  • Thank you received: 26
  • Karma: 6
Don't forget about calendar corrections from the Gregorian to Julian calendar.

Especially beware of dates sourced from different countries as this change happened at different times, years apart, depending on the country.
Online since 1996.
The administrator has disabled public write access.
Time to create page: 0.099 seconds

Get Started