Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi I have 4 date formats, and there might be chance of adding new format in the date column all need to be converted into 'MM/DD/YYYY' format
date_e:
12/20/2025
12.20.2025
20.12.2025
20-01-2025
20-01-2025 12:12:11
20/12/2025 12;12:11
All the above needs to be converted into 'MM/DD/YYYY' format, is there a way doing this
Date(
Alt(
Date#(date_e,'MM/DD/YYYY'),
Date#(date_e,'MM.DD.YYYY'),
Date#(date_e,'DD.MM.YYYY'),
Date#(date_e,'DD-MM-YYYY'),
Floor(TimeStamp#(date_e,'DD-MM-YYYY hh:mm:ss')),
Floor(TimeStamp#(date_e,'DD/MM/YYYY hh:mm:ss')),
)
,'MM/DD/YYYY')
Hi thanks @BrunPierre this covers only the above specific formats,is there is any other way that formats the above date fields into 'MM/DD/YYYY'
If for example MM.DD.YYYY, if that formats has been added to the dataset,every time we needto add that logic date# logic to that formats, can we have a single solution for all the date formats please @BrunPierre
You may have to standardize the date formats in your source data. This way, Qlik always receives dates in a single, consistent format.
or
If your dates are consistently in the order of month, day, and year across your dataset, you can use the following workaround
Date(
Date#(
Replace(Replace(date_e, '.', '/'), '-', '/'),
'MM/DD/YYYY'
),
'MM/DD/YYYY'
)
Try this
Data:
LOAD
Date(Alt(
Date#(date_e, 'MM/DD/YYYY'),
Date#(date_e, 'MM.DD.YYYY'),
Date#(date_e, 'DD.MM.YYYY'),
Date#(date_e, 'DD-MM-YYYY'),
Date#(date_e, 'DD-MM-YYYY hh:mm:ss'),
Date#(date_e, 'DD/MM/YYYY hh:mm:ss')
), 'MM/DD/YYYY') AS FormattedDate
FROM Source;