Formatting text as date in evaluator column script

I’m trying to setup an evaluator column that pulls out a date from a series of log extracts.

Example File: extract_22_06_2021.log

This is the script I’m using to pull this out and it works ok but the date is in text format when I want it recognised as a date.

logDate = RegEx(name, "extract_(.+).log", "\1");

if (logDate == name)

{

return "";

}

else{

return logDate;

}

If I modify the return value from

return logDate;

to

return logDate As date;

The date in the column is then shown as 01/01/1601 so I’m assuming it’s not recognising it correctly as a date. Should ‘22_06_2021’ be recognised as a date and if not what do I need to do for it to be recognised as a date?

No it won't be recognised, it needs to be in the format YYYY-MM-DD. You'll need to use the regex to pull out the individual parts and rearrange them, e.g.

logDate = RegEx(name, "extract_(\d+)_(\d+)_(\d+)\.log", "\3-\2-\1");

Works perfectly. Thanks for the quick response.