04-05-2015, 07:49 AM | #1 |
Enthusiast
Posts: 30
Karma: 10
Join Date: Sep 2014
Device: none
|
Custom column: "pubdate" and "ifempty"
I've been using code like "{languages:ifempty(-)}" in a custom combined column successfully. I've been trying a similar approach for a custom formatted "pubdate", but I can't figure out the correct syntax. Could someone give me a simple example please? I'm not a "real" coder, so the Calibre manual is much too complicated for me... I'd like to have the pubdate formatted as "MMM yyyy", with a "-" character if the field is empty (= no pubdate set). Date formatting works fine ("{:'format_date(raw_field('pubdate'),'yyyy')'} "), and "ifempty" works fine, too - I just don't know how to combine the functions properly.
EDIT: solved the problem by creating another custom column which stores the formatted pubdate. I'd still be interested in knowing if there's a way to get the formatted date without using an additional column. Last edited by StillReading; 04-05-2015 at 08:03 AM. |
04-05-2015, 05:32 PM | #2 |
Grand Sorcerer
Posts: 11,772
Karma: 7029857
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
I think that this template does what you want:
Code:
{:'ifempty(format_date(raw_field('pubdate'),'yyyy'), '-')'} |
Advert | |
|
04-06-2015, 09:56 PM | #3 |
Enthusiast
Posts: 30
Karma: 10
Join Date: Sep 2014
Device: none
|
Thanks, that works beautifully! I've played around a bit with the "{fieldname:|Prefix|Suffix}" syntax and tried to combine that approach with your example, but couldn't get it working properly. Best I got was the formatted pubdate, directly followed by the "raw" pubdate value. I think this is because of improper quoting (I've tried various combinations), or maybe it's not possible to combine two functions.
For anyone playing around with combined fields: I found that if you let Calibre display a combined field as a column in the "grid view", and single click on a row in that column (just like you would when you'd wanted to edit a value), Calibre lets you edit the function directly with a live preview of the result (!). I don't think that functionality is explained in the manual, it's very helpful when playing around with functions. |
04-07-2015, 01:04 AM | #4 | ||
Grand Sorcerer
Posts: 11,772
Karma: 7029857
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Quote:
|
||
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Custom column not recognized in "Sending books to devices" | cheveguerra | Devices | 4 | 12-05-2011 01:58 PM |
Custom column: "Updated date", when adding new "versions" of the same file? | enriquep | Library Management | 16 | 11-03-2011 10:46 AM |
Sony PRS-T1 and plugboards "tags" from custom column | salines | Devices | 8 | 10-31-2011 03:00 AM |