View Single Post
Old 09-28-2024, 12:39 PM   #2
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 12,461
Karma: 8025600
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by Wiggo View Post
I have a column (#startdates) with comma separated text, like tags, with a date in the following format: 2024.09.21

I want to insert this date into a date column (#dateread) with the format 'dd MMM yyyy'.

Could someone please help me?

Edit: Or does it work easier with action chain and a template?

Attachment 211076
Is the date always the first value in #startdates? The only value? The last value? If not, how do you know which value to use?

If it is the first or only value, then I suggest you use a search & replace using "Template" as the source. The template would be
Code:
program: format_date(sublist(#startdates, 0, 1, ','), 'dd MMM yyyy')
If it is the last value then this should work:
Code:
program: format_date(sublist(#startdates, -1, 0, ','), 'dd MMM yyyy')

The search & replace dialog contents:
  • Search mode: Regular expression
  • Search field: {template}
  • Template: as above
  • Search for: ^(.*)$
  • Replace with: \1
  • Destination field: #dateread
If the date is buried somewhere in a multi-valued column then things are more complicated. You will need to search in the template for the date probably using a for loop, processing the first date you find.

As always, be careful when using search & replace. Try it on a few books before running it on your entire library. Backing up your library is a good plan.
chaley is offline   Reply With Quote