View Single Post
Old 12-21-2012, 12:49 AM   #1
bookworm2000
Member
bookworm2000 is a jewel in the roughbookworm2000 is a jewel in the roughbookworm2000 is a jewel in the roughbookworm2000 is a jewel in the roughbookworm2000 is a jewel in the roughbookworm2000 is a jewel in the roughbookworm2000 is a jewel in the roughbookworm2000 is a jewel in the roughbookworm2000 is a jewel in the roughbookworm2000 is a jewel in the roughbookworm2000 is a jewel in the rough
 
Posts: 14
Karma: 7220
Join Date: Dec 2012
Device: Kindle 4NT, Android
Date formatting/template program mode

Hi everyone,

this is my first post, thank you for taking the time to look into my problem.

Which is...

I use a custom column to store the publishing dates of magazines. These come in various formats like
  • 1955.04.20 (most exact)
  • 1955.04
  • 1955
  • 1955.Spring
  • 1955.Spring/Summer (worst case)

So I use strings instead of dates or numbers.

These of course don't sort exactly but can easily be found as hierarchical items in the tag browser.

Now I want to extract a formatted date from this data:

1955.04.20
should be
1955-04-20

1955.04
should be
1955-04-00

1955
should be
1955-00-00

1955.Spring
should be
1955-00-00

1955.Spring/Summer
should be
1955-00-00

(the season data should be omitted completely).

What I have so far:

3 (hidden) columns to isolate year, month and day:
{#original_date:subitems(0,1)}
{#original_date:subitems(1,2)}
{#original_date:subitems(2,3)}

and a fourth to build the formatted date:
{#original_year:ifempty(0000)}-{#original_month:ifempty(00)}-{#original_day:ifempty(00)}

What I want to achieve:
  1. get them all into one column
  2. check the month for non-integer data and replace it with "00"

So far I haven't wrapped my brain around the template program mode, I don't find a way to combine subitems() and ifempty().

Thanks in advance!
bookworm2000 is offline   Reply With Quote