Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre > Library Management

Notices

Reply
 
Thread Tools Search this Thread
Old 01-02-2024, 08:57 AM   #1
Cattivix
Junior Member
Cattivix began at the beginning.
 
Posts: 1
Karma: 10
Join Date: Jan 2024
Device: Kobo Libra 2
Custom column calculating time taken to read a book

Hi guys!

I've been using Calibre for a couple of years but now that I started to read solely on e-ink I've been trying to make my library a bit "smarter".

I'd like to add a custom column which calculates the days I took to read a book from my #started and my #finished date columns, both in dd MM yyyy.

I've browsed the General Program Mode wiki on Calibre but honestly it's overwhelming. Is the function supposed to be written in the "template" line in the custom column? I also found a reddit post mentioning some kind of "editor" where I quickly can test the functions.

Honestly looking at the wiki it doesn't even look like I can do calculations with the date format. Should I make a plugin instead? How hard is it?

Thanks in advance
Cattivix is offline   Reply With Quote
Old 01-02-2024, 09:04 AM   #2
theducks
Well trained by Cats
theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.theducks ought to be getting tired of karma fortunes by now.
 
theducks's Avatar
 
Posts: 30,009
Karma: 57259778
Join Date: Aug 2009
Location: The Central Coast of California
Device: Kobo Libra2,Kobo Aura2v1, K4NT(Fixed: New Bat.), Galaxy Tab A
Snipped from the Calibre Help page:Search & sort

Code:
Dates

The syntax for searching for dates is:

pubdate:>2000-1 Will find all books published after Jan, 2000
date:<=2000-1-3 Will find all books added to calibre before 3 Jan, 2000
pubdate:=2009 Will find all books published in 2009

If the date is ambiguous then the current locale is used for date comparison. For example, in an mm/dd/yyyy locale 2/1/2009 is interpreted as 1 Feb 2009. In a dd/mm/yyyy locale it is interpreted as 2 Jan 2009. Some special date strings are available. The string today translates to today’s date, whatever it is. The strings yesterday and thismonth (or the translated equivalent in the current language) also work. In addition, the string daysago (also translated) can be used to compare to a date some number of days ago. For example:

date:>10daysago
date:<=45daysago

To avoid potential problems with translated strings when using a non-English version of calibre, the strings _today, _yesterday, _thismonth, and _daysago are always available. They are not translated.

Searching dates and numeric values with relational comparisons

Dates and numeric fields support the relational operators = (equals), > (greater than), >= (greater than or equal to), < (less than), <= (less than or equal to), and != (not equal to). Rating fields are considered to be numeric. For example, the search rating:>=3 will find all books rated 3 or higher.

You can search for books that have a format of a certain size like this:

        size:>1.1M will find books with a format larger than 1.1MB

        size:<=1K will find books with a format smaller than or equal to 1KB

You can search for the number of items in multiple-valued fields such as tags using the character # then using the same syntax as numeric fields. For example, to find all books with more than 4 tags use tags:#>4. To find all books with exactly 10 tags use tags:#=10.
These can be used in a calculated from others field (I am not a expert at that )
theducks is offline   Reply With Quote
Advert
Old 01-06-2024, 08:02 PM   #3
dunhill
Guru
dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.dunhill ought to be getting tired of karma fortunes by now.
 
dunhill's Avatar
 
Posts: 735
Karma: 228142
Join Date: Sep 2017
Location: Argentina
Device: moon+ reader, kindle paperwhite
I have the following code for what you ask for, because I also use it and I have asked about it in the forum, since I couldn't find the original message I'll leave it here.
Create a custom column of name days
Column generated from other columns
In template paste this code adding the name of your columns of the start and end dates of readings
Code:
 program: format_number(days_between(raw_field('#your date column ended'), raw_field('#your date column started')),"{0:5.0f}")
and it will look like the picture
Attached Thumbnails
Click image for larger version

Name:	1.png
Views:	33
Size:	53.0 KB
ID:	205629  

Last edited by dunhill; 01-06-2024 at 08:04 PM.
dunhill is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[Browser Viewer] Time to read -- > Calculating nqk Server 1 01-24-2021 12:05 AM
Custom column that lists date AND time a book is added cscoley Calibre 14 05-01-2019 04:20 PM
Custom Column to enter date a book was completed (was read) Acousticvillage Library Management 6 12-08-2018 05:02 PM
Creating Custom Column for Read and Date Read library addict Calibre Companion 11 03-22-2014 05:33 AM
Custom column read ? pchrist7 Calibre 2 10-04-2010 02:52 AM


All times are GMT -4. The time now is 08:04 AM.


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