Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 06-30-2019, 12:15 PM   #1
China Diapers
Member
China Diapers began at the beginning.
 
Posts: 21
Karma: 10
Join Date: May 2011
Device: PRS-600
Result of difference between two dates populated in a column

I have added two custom columns to Calibre, 'Start' and 'Finish', both hold date values. I want to calculate the number of days difference between these two date values and populate this in a third column.

Is this possible?
China Diapers is offline   Reply With Quote
Old 06-30-2019, 02:12 PM   #2
DaltonST
Deviser
DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.DaltonST ought to be getting tired of karma fortunes by now.
 
DaltonST's Avatar
 
Posts: 2,265
Karma: 2090983
Join Date: Aug 2013
Location: Texas
Device: none
Yes, if you create a template function to do so.

See: https://manual.calibre-ebook.com/template_lang.html

Create a custom composite column to test templates. Once you have the column, you can change its template simply by double-clicking on the column.
DaltonST is offline   Reply With Quote
Advert
Old 06-30-2019, 04:57 PM   #3
China Diapers
Member
China Diapers began at the beginning.
 
Posts: 21
Karma: 10
Join Date: May 2011
Device: PRS-600
Quote:
Originally Posted by DaltonST View Post
Yes, if you create a template function to do so.

See: https://manual.calibre-ebook.com/template_lang.html

Create a custom composite column to test templates. Once you have the column, you can change its template simply by double-clicking on the column.
Many thanks, I shall take a look.
China Diapers is offline   Reply With Quote
Old 07-06-2019, 08:54 AM   #4
China Diapers
Member
China Diapers began at the beginning.
 
Posts: 21
Karma: 10
Join Date: May 2011
Device: PRS-600
Quote:
Originally Posted by DaltonST View Post
Yes, if you create a template function to do so.

See: https://manual.calibre-ebook.com/template_lang.html

Create a custom composite column to test templates. Once you have the column, you can change its template simply by double-clicking on the column.
I have been experimenting with this and something strange is happening. I have created a column with type 'Column built from other columns' and tried entering the below in the template field:

days_between({#start_date},{#end_date}) returns "days_between(,)"
days_between(#start_date,#end_date) returns "days_between(#start_date,#end_date)"

What am I doing wrong?

Last edited by China Diapers; 07-06-2019 at 01:21 PM.
China Diapers is offline   Reply With Quote
Old 07-07-2019, 01:50 AM   #5
China Diapers
Member
China Diapers began at the beginning.
 
Posts: 21
Karma: 10
Join Date: May 2011
Device: PRS-600
If I populate the template field with an example from the manual, e.g. :

Quote:
{author_sort}/{title}/{title} - {authors}
It works, but not my days_between example.
China Diapers is offline   Reply With Quote
Advert
Old 07-07-2019, 03:43 AM   #6
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 21,721
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
@China Diapers - a search in MR for days_between found me this ==>> https://www.mobileread.com/forums/sh...15&postcount=6

BR
BetterRed is offline   Reply With Quote
Old 07-07-2019, 04:29 AM   #7
China Diapers
Member
China Diapers began at the beginning.
 
Posts: 21
Karma: 10
Join Date: May 2011
Device: PRS-600
Quote:
Originally Posted by BetterRed View Post
@China Diapers - a search in MR for days_between found me this ==>> https://www.mobileread.com/forums/sh...15&postcount=6

BR
Thank you. Strange that worked for them, rather counter-intuitive. I enter:

Quote:
days_between(field('#start_date'),field('#end_date '));
and in the result column I see the template expression rather than calculated result:

Code:
days_between(field('#start_date'),field('#end_date'));

Last edited by China Diapers; 07-07-2019 at 04:32 AM.
China Diapers is offline   Reply With Quote
Old 07-07-2019, 04:48 AM   #8
BetterRed
null operator (he/him)
BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.BetterRed ought to be getting tired of karma fortunes by now.
 
Posts: 21,721
Karma: 29711016
Join Date: Mar 2012
Location: Sydney Australia
Device: none
See Using general program mode

Code:
program:
    days_between(field('#start_date'),field('#end_date'));
BR
BetterRed is offline   Reply With Quote
Old 07-07-2019, 04:53 AM   #9
China Diapers
Member
China Diapers began at the beginning.
 
Posts: 21
Karma: 10
Join Date: May 2011
Device: PRS-600
Quote:
Originally Posted by BetterRed View Post
See Using general program mode

Code:
program:
    days_between(field('#start_date'),field('#end_date'));
BR
Thank you very much!

I have returned to using calibre after a few years, had no idea how powerful it is.
China Diapers is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding custom column with any lookup-name gives me empty column as a result? Ahu Lee Library Management 16 06-09-2019 12:14 PM
Using "Build column from other column" custom-column type HFC3 Library Management 3 07-07-2013 03:11 AM
Date column giving me incorrect result James76 Library Management 3 12-22-2011 09:24 PM
North America was populated by no more than 70 people 14,000 years ago ardeegee Lounge 2 05-11-2011 07:33 PM
Ebook-convert.exe and Win/Mac result difference marekl Calibre 5 01-19-2011 03:18 PM


All times are GMT -4. The time now is 05:15 AM.


MobileRead.com is a privately owned, operated and funded community.