Correct Date Format

0
I’m having an issue when importing dates from an Excel file into my Mendix application. I need to implement a validation check to ensure users enter the correct date format. I want to validate the imported dates and prevent users from entering dates in the wrong formats. Examples: 1.Correct: “DD-MM-YYYY” (e.g., “18-08-2024”)  2. Incorrect: “MM/DD/YYYY” (e.g., “08/18/2024”) 3.Incorrect: “DD/MM/YYYY” (e.g., “18/08/2024”) 4.Incorrect: “MM/DD/YYYY” (e.g., “18/08/2024”) So only accept the first option. Despite the dates being formatted as “DD-MM-YYYY” in Excel, the debugger in Studio Pro shows them as “MM/DD/YYYY”.Could anyone provide guidance on how to implement this validation effectively in my microflow? Thank you!
asked
2 answers
1

Hi Selcuk,

 

First change your entity attribute from DateTime to String 

Go to import excel microflow store the rowCount in the integer variable $rowCountStoreValue.

Retrieve your currently imported data in the xpath select custom and in the 

amount section just pass this variable $rowCountStoreValue and sort on the basis of currDateTime in decending order 

 

Now you have exactly currently imported data,

 

Create a boolean variable $IsDate(false) and take a loop pass currently retrieve list and iterate them

in the decision box check isMatch($Iterator/Date ,’\d{2}-\d{2}-\d{4}’) if this true do continue but if this false means we have another format of date 

Change the $IsDate(true) & break the loop.

 

Lastly Outside of this loop just take a decision in the decision check $IsDate=true means list have some another format of date  value just show a validation feedback please enter correct date format and delete the retrieve list but if $IsDate=false means there have all corrected date value just show message successfully imported & end the event.

 

Hope you like the answer.

 

IMG_5632.png

answered
0

Hi Selcuk,

 

Sounds like your dates in excel are stored as dates, because of this it will use the excel date format.  The excel importer will fail any rows that do not have a parse-able date.  You can use the localization built into Mendix to have the date formatted in the user's country's common format.  You can also override this behavior in App Settings -> Language tab.

answered