Working with dates from various formats (origins ?)

Hi all,

I was trying to deal with dates that can come from many (any ?) origins.

The first thing to do is to standardize the field separator (to ‘-’)

Next, is to add an eventual leading zero.
Here a decision have to be done: do fields with only one digits are only Days and / or Months ?
My answer is Yes ! I never saw a year number set using a single digit (for 1900 to 1909 / 2000 to 2009 as examples).

Then, I have to determine the order of appearance of the Day, Month and Year fields: not tested yet, but … done.

And now the importand part: How to deal with the century ?
The case is, people use only two digits for the century # (They never heard of … the bug of the century in WIndows…).

Until now, my position was: a year tha have a value: current year + 2 is in the previous century. this year and next year are from the current century.

So, I insert 19 or 20 following that rule (before the two digits of the short year # to get a date with the Century).

What is your position ? :wink:
(How do you deal with that ?).

Edit: What I call Century above is in fact… the Millenium + Century numbers (19 or 20).

BTW: ParseDate is useless here.
The target date format is SQL Date (YYYY-MM-DD)

Nota: this is for the cases the user import (a file or by a Copy / Paste) data without the century set for the year #.
If the user have to write its own date, there are solutions to avoid 2 digit years and depending on the context, avoid “strange” year numbers (like some living person whose birth year is set to 1848 (for example).
The date of abolition of slavery in France is 27 April 1848. Someone may enter 1848 for a Date of Birth instead of 1948 (because s/he was working on an article about slavery in France…).

for fun: how do you check the 12th december 2012 …
it can be shown as 12-12-12 …

[quote=336780:@Jean-Yves Pochez]for fun: how do you check the 12th december 2012 …
it can be shown as 12-12-12 …[/quote]
For that specific case it does not matter! All return 12 December 2012 (assuming Emile’s year handling).

so 12-11-12 ?
:wink:

Thank you for the questions. You do not seems to go thru that way before today.

The handling ? I do not do the conversion of ONE date, but on a set of dates. When you have tens or hundreds or more dates… you may be able to rely on the group.

Changes are you have a collection of days (from 1 thru 31) months (from 1 thru 12) and for years… (from 00 thru 99) !
There is no one thru thrity one (I talked about leading zeroes)…
And, there is no January thru December in this. Only numbers. (I talked about leading zeroes).

BTW: this was implicit (sorry) in my original question: I do not took a month in characters into consideration. I had in mind some wikipedia pages that displayed (I do not found the original page with three different dates formats appended to the list).

Numeric only dates are … such fun
09-10-11 - is this dd-mm-yy, mm-dd-yy, yy-mm-dd, yy-dd-mm or ???
Worse EVERY one is actually a legal date and you have no best way to know

Just use a popup calendar and do not allow text entry. That way it is easy to standardise.

I recommend Einhugur’s though there is a free one available here on the forums too.

P.S. It’s at https://github.com/IntelligentVisibility/CalendarTimeChooser

Norman, Markus: thank you for your answers.

Unfortunately, this was not the answer to the question. For that question, I already use a solution with three PopupMenus too choose a date: as Markus wrote: the only real error is a wrong selection and in case of living persons, I add a year’s old test: no baby with -5 years old and no oldster that be 150 years old :wink:
AFAIK, no more errors since I add that.

BTW: Hasta La Vista Baby in a couple of minutes on TV (Terminator Renaissance / Terminator Rebirth ? --> TMC, French TV)

EyeTV, I’m coming…

[quote=336780:@Jean-Yves Pochez]for fun: how do you check the 12th december 2012 …
it can be shown as 12-12-12 …[/quote]
Having fun with Emile:

First, I do not deal with this kind of date (12th december 2012).
Second, I deal with 12-12-12 and I always get the right fields values in the correct Day, Month and Year.

Yes, when you have hundreds, thousands of values to check, a simple (!) check allows you to get the correct values.

In a loop, you check each (of the three) field(s), and store the value in an array (three arrays).
At the end of the loop, you make three Sort (one for each Array),

Then, You check the higher value for each Array.
If the max value is below 32 —> It’s a Day !
If the max value is below 13 —> It’s a Month !
If the max value is above 32 —> It’s a Year !

No, It’s Superman !!! :wink:

As I wrote earlier, it is easy.

Note: statistically, and talking of Birth dates, you will get many years that are above 31 (and I do not talk about the day and month numbers that are far easier to know what is what).

What do we need to achieve a task ?
Knowledge, search, time, be ingeniously, be cool, no noise (or noise, depends: I can be prolific writing code in a full McDonald’s !).
And “With a little help from my friend”s from this forum, I can go ahead when I am facing troubles.

– 1969:
Wight is Wight
Dylan is Dylan