Forum Discussion

G_Whit-UK's avatar
G_Whit-UK
Icon for Helper II rankHelper II
6 years ago
Solved

Inconsistent date format in source data

Hi   I am importing data from a PDF table.  One of the columns is a date field, and I've found examples where the date formatting is inconsistent (mm/dd/yyyy vs dd/mm/yyyy).  The majority of the PD...
  • Anonymous's avatar
    Anonymous
    6 years ago

    Hi G_Whit-UK 

     

    Expanding on mahoneypat suggestion.

     

    You can test the entire piece of input data first to decide which data format to use. Add a column with something like try Date.From(...) otherwise "FAILED" and then test the added column for the presence of "FAILED" (group/count or filter/row count).

     

    If all good use Date.From(...) to convert text to dates, otherwise Date.From(..., "en-US").

     

    You can go even further depending on what date you load and how they are stored. E.g. if this is only same month data, i.e. report called 31 Jan 2020 only contains Jan data you can test that you do not have any months in the output other then contained in the report file name (this is to fight 1/11 vs. 11/1 cases).

     

    Kind regards,

    JB