Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 674203
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T00:40:48+00:00 2026-05-14T00:40:48+00:00

I have to migrate a very large dataset from one system to another. One

  • 0

I have to migrate a very large dataset from one system to another. One of the “source” column contains a date but is really a string with no constraint, while the destination system mandates a date in the format yyyy-mm-dd.

Many, but not all, of the source dates are formatted as yyyymmdd. So to coerce them to the expected format, I do (in Perl):

return "$1-$2-$3" if ($val =~ /(\d{4})[-\/]*(\d{2})[-\/]*(\d{2})/);

The problem arises when the source dates moves away from the “generic” yyyymmdd. The goal is to salvage as many dates as possible, before giving up. Example source strings include:

21/3/1998,
March 2004,
2001,
3/4/97

I can try to match as many of the examples I can find with a succession of regular expressions such as the one above.

But is there something smarter to do? Am I not reinventing the wheel? Is there a library somewhere doing something similar? I couldn’t find anything relevant googling “forgiving date parser”. (any language is OK).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T00:40:48+00:00Added an answer on May 14, 2026 at 12:40 am

    I finally extracted a test set of more than 200 examples of dates that actually occur in the data set. Some are mildly misbehaved, a few are totally sick (“01010” for example).

    I tried all the existing Perl modules I could find, but the success rate was too low. I eventually dived in an reinvented my wheel, achieving a more than 98% success rate.

    My algorithm is a succession of increasingly fuzzier recognizers, starting with the rigidly valid dates downs to total guess territory. The first to return a “success” result wins. In the middle of that stack, I have the “main” recognizer which does something like this:

    • parse sets of numbers in the string, anywhere. “months names” in French and in English are recognized also.

    • For each of them I put them in three buckets: candidates for year, candidates for month, candidates for day. For example “13” will be in the “possible year” bucket, and in the “possible day” bucket. “February” will only go in the “months” bucket of course. In each bucket, the value is tagged with a “plausibility level”, an arbitrary number that depends on a number of things. For example, 2010 is more plausible as a year than 10.

    • look in each of the three buckets. If any of them has only one item in it, it’s the value for that bucket. It’s also removed from the other buckets.

    • look for the remaining missing values in their respective buckets in order (year, month, day), taking the one with the highest plausibility. In case of tie, take the one occurring last in the string (actually, those have slightly higher plausibility). This rules breaks 7/3/2010 as march 7, as I need here in France. Remove that value from the other buckets, should the case apply.

    • if any value is missing, use a default value (eg I use 8191 as the default year, the largest allowed value in my target system).

    The whole thing is awfully heuristics, but fits my requirement that it’s better to have garbage than to lose information.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a very simple bash script to help me migrate from dev
I have a library, and I want to migrate it from an old system
I have to migrate a table from MSSQL Server to MySql. The problem is
I have an application that we're trying to migrate to 64bit from 32bit. It's
We have a fairly large SVN repository which we are looking to migrate to
We have recently migrated a large, high demand web application to Tomcat 5.5 from
I have a very large program which I have been compiling under visual studio
I have a truckload of xsd with plain SQL queries. I want to migrate
On a quest to migrate some new UI into Managed/C# land, I have recently
I have a solution containing several projects that have migrated from VS 2003, 2005,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.