01-13-2014, 11:55 AM | #1 |
Zealot
Posts: 114
Karma: 6288
Join Date: Dec 2012
Device: iphone
|
Custom Column Date Question
I have a custom column (releasedate) with a date in it. The date is formatted dd mmm yy (13 Jan 13) and I want to leave this column alone.
I need another column that will look at this column and give me mmyy (0113). I have tried several ways but I keep getting the strangest results. Can someone give me a hand. Thanks you. |
01-13-2014, 12:22 PM | #2 |
Grand Sorcerer
Posts: 12,032
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
The template to use in the "column built from other columns" is
Code:
{#mydate:format_date(MMyy)} Explanation: mm is minutes, 2 digits with a leading zero. MM is the month, again 2 digits with a leading zero. |
Advert | |
|
01-13-2014, 12:24 PM | #3 |
Well trained by Cats
Posts: 30,451
Karma: 58055868
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
|
http://manual.calibre-ebook.com/template_lang.html
in the section Code:
format_date(x, date_format) – format_date(val, format_string) – format the value, which must be a date field, using the format_string, returning a string. The formatting codes are: Why bloat the DB with 2 columns of the essentially the same data with a display variant? If you need MMYY on an export, do it (the format conversion) in the save template If you want the GUI to SHOW MMYY Preferences: Add your own column: (select your column name):click the blue i and change the Format for dates (this is a Display format, not the data format, which is still a full date) |
01-13-2014, 05:07 PM | #4 |
Zealot
Posts: 114
Karma: 6288
Join Date: Dec 2012
Device: iphone
|
Chaley that's perfect.
Just purely out of curiosity is it possible to take this one step further? #column1 - numeric value #column2 - fixed set of values, but only 1 is relevant here #column3 - date Is it possible to: If #column1 >1 AND #column2=blue then {#column3:format_date(MMyy)} otherwise blank Just pushing my luck. Tired of doing things manually. Thanks |
01-13-2014, 06:01 PM | #5 | |
Grand Sorcerer
Posts: 12,032
Karma: 7257323
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
|
Quote:
Code:
program: cmp( field('#column1'), 1, '', '', strcmp( field('#column2'), 'blue', '', format_date(field('#column3'), 'MMyy'), '' )) |
|
Advert | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Date custom column built from a Y/N one? | glos | Library Management | 3 | 08-25-2013 01:48 PM |
Bulk Clear Custom Column Date - Not Working | BetterRed | Calibre | 5 | 02-23-2013 06:04 AM |
custom date column from two state column | Dopedangel | Library Management | 7 | 01-03-2012 09:20 AM |
Question about the default 'Date' column | jukin | Calibre | 5 | 08-31-2011 09:15 PM |
Custom column for date added | Gunnerp245 | Calibre | 2 | 07-08-2011 05:39 PM |