Scan text for date—desired date format

The problem

I have a smart rule which scans the name of a markdown file. The file name contains the date in the format “Wednesday 2 June 2021”. I have a custom metadata date field (date only) in which I should like to put that date—but in the format 02/06/2021. I can’t seem to do that.

The handbook

The handbook says, on page 228:

Date: Similar to String parameter, use the desired format of the Document Date placeholder to represent the captured string in subsequent actions.

What I seem incapable of working out is how to change the date format from the captured to the “desired format”. Am I correct in thinking <shudder> that this is something for scripting (although the handbook appears to hint at something simpler)?

Apologies if I’ve missed something simple!

Stephen

The scan actions do not expect a date format but either a prefix and/or suffix. E.g. if the date follows always the string “DATE:”, then this DATE:* should work.

Thanks for the reply. I seem to be able to extract what appears to be the date with no problem. It’s the format in the custom metadata date field that’s the problem.

Maybe I should explain a little more. Take the following named files:

Tuesday 1 June 2021.md
Monday 31 May 2021.md
Thursday 31 December 2020.md

Run the following smart rule on those files:

2021-06-02_10-24-44

and I end up with this:

2021-06-02_10-26-40

Stephen

The rule seems to use custom metadata, is this a string or date?

It is a custom metadata date field set to date only. The Diary entry date column is sortable by date so the data clearly is treated as a date.

Stephen

The display format of custom metadata dates can’t be customized (yet), therefore the only workaround would be use to a string.

Ah OK, thanks for that: at least I know it’s not me being stupid!

It’s not a disaster by any means but I am encouraged by your “(yet)”.

Stephen

Actually this just means that it might be possible in the future but not anytime soon (too much already to do as usual).

I do understand and really appreciate the development of DT and all the help you all give on this forum. I can live with what I have at the moment!

Stephen

3 Likes