Register Guidelines E-Books Today's Posts Search

Go Back   MobileRead Forums > E-Book Software > Calibre

Notices

Reply
 
Thread Tools Search this Thread
Old 03-18-2022, 10:55 AM   #1
quarkpott
Member
quarkpott began at the beginning.
 
Posts: 22
Karma: 10
Join Date: Jul 2017
Device: none
Calculate difference on two dates

Hello,

Maybe someone can help me.
I have a Read Start column and a Read End column. How can I create a read duration column that shows the days between the two dates? How can I create a read duration column that shows the days between the two dates?
I need a column that depends on other columns, but then unfortunately I do not get more.

I would be very glad about help.
quarkpott is offline   Reply With Quote
Old 03-18-2022, 11:12 AM   #2
chaley
Grand Sorcerer
chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.chaley ought to be getting tired of karma fortunes by now.
 
Posts: 11,760
Karma: 7029857
Join Date: Jan 2010
Location: Notts, England
Device: Kobo Libra 2
Quote:
Originally Posted by quarkpott View Post
Hello,

Maybe someone can help me.
I have a Read Start column and a Read End column. How can I create a read duration column that shows the days between the two dates? How can I create a read duration column that shows the days between the two dates?
I need a column that depends on other columns, but then unfortunately I do not get more.

I would be very glad about help.
See The calibre template language, General Program Mode, and in particular the days_between() function.

You probably want a template like this, with the lookup names changed appropriately.
Code:
program:
    days_between($$#read_end, $$#read_start)
The days_between() function returns fractional days. If you want an integer then use either
Code:
program:
    floor(days_between($$#read_end, $$#read_start))
Code:
program:
    round(days_between($$#read_end, $$#read_start))
chaley is offline   Reply With Quote
Advert
Old 03-18-2022, 11:18 AM   #3
quarkpott
Member
quarkpott began at the beginning.
 
Posts: 22
Karma: 10
Join Date: Jul 2017
Device: none
Thanks, I'll look into it and get back to you if I can't get it to work.
quarkpott is offline   Reply With Quote
Old 03-18-2022, 05:06 PM   #4
quarkpott
Member
quarkpott began at the beginning.
 
Posts: 22
Karma: 10
Join Date: Jul 2017
Device: none
I think I don't understand something.
I have copied in the templates and changed for me and have specified the template in the column. Shouldn't it actually work then?
Please excuse my stupidity
Attached Thumbnails
Click image for larger version

Name:	spalte.png
Views:	51
Size:	50.2 KB
ID:	192834   Click image for larger version

Name:	lesedauer.png
Views:	57
Size:	102.2 KB
ID:	192835  
quarkpott is offline   Reply With Quote
Old 03-18-2022, 05:28 PM   #5
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,721
Karma: 62000001
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Code:
program: Lesedaeur()
ownedbycats is offline   Reply With Quote
Advert
Old 03-18-2022, 05:30 PM   #6
quarkpott
Member
quarkpott began at the beginning.
 
Posts: 22
Karma: 10
Join Date: Jul 2017
Device: none
Quote:
Originally Posted by ownedbycats View Post
Code:
program: Lesedaeur()
Then 0 is displayed in the column, although it should actually be 2
quarkpott is offline   Reply With Quote
Old 03-18-2022, 05:43 PM   #7
quarkpott
Member
quarkpott began at the beginning.
 
Posts: 22
Karma: 10
Join Date: Jul 2017
Device: none
With some experimenting it worked now, thank you.
quarkpott is offline   Reply With Quote
Old 03-18-2022, 06:12 PM   #8
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,721
Karma: 62000001
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
If it helps for the future, I've found most of my days_between() errors happened because I put the two dates in the wrong order.
ownedbycats is offline   Reply With Quote
Old 03-19-2022, 11:25 AM   #9
quarkpott
Member
quarkpott began at the beginning.
 
Posts: 22
Karma: 10
Join Date: Jul 2017
Device: none
Me again.
Is it perhaps also possible that the field is only populated when Read Begin and Read End are filled in?
At the moment there is always a 0 entered.
Thanks in advance for the effort.
quarkpott is offline   Reply With Quote
Old 03-19-2022, 11:51 AM   #10
ownedbycats
Custom User Title
ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.ownedbycats ought to be getting tired of karma fortunes by now.
 
ownedbycats's Avatar
 
Posts: 8,721
Karma: 62000001
Join Date: Oct 2018
Location: Canada
Device: Kobo Libra H2O, formerly Aura HD
Quote:
Originally Posted by quarkpott View Post
Me again.
Is it perhaps also possible that the field is only populated when Read Begin and Read End are filled in?
At the moment there is always a 0 entered.
Thanks in advance for the effort.
Is odd as I just got a blank, but hopefully this will work:

Code:
program:

	if 
		$$#date1 && $$#date2
	then
		days_between($$#date1, $$#date2)
	fi

Last edited by ownedbycats; 03-19-2022 at 02:01 PM.
ownedbycats is offline   Reply With Quote
Old 03-20-2022, 02:27 PM   #11
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: 728
Karma: 228142
Join Date: Sep 2017
Location: Argentina
Device: moon+ reader, kindle paperwhite
I have it configured like this
Taking the start and read ended column
Code:
program: format_number(days_between(raw_field('#finished'), raw_field('#started')),"{0:5.0f}")
dunhill is offline   Reply With Quote
Old 03-20-2022, 03:18 PM   #12
quarkpott
Member
quarkpott began at the beginning.
 
Posts: 22
Karma: 10
Join Date: Jul 2017
Device: none
Thank you. Worked.
Slowly it becomes as desired.

I also have books that I have read but have not set a date.
Is it perhaps also possible to write an unknown for these in Read Start, Read End and read duration?

Last edited by quarkpott; 03-20-2022 at 03:29 PM.
quarkpott is offline   Reply With Quote
Old 03-20-2022, 03:31 PM   #13
quarkpott
Member
quarkpott began at the beginning.
 
Posts: 22
Karma: 10
Join Date: Jul 2017
Device: none
That would be the last one, sorry for all the questions.
quarkpott is offline   Reply With Quote
Old 03-20-2022, 04:07 PM   #14
quarkpott
Member
quarkpott began at the beginning.
 
Posts: 22
Karma: 10
Join Date: Jul 2017
Device: none
Got it myself, thanks anyway for all the help here
quarkpott is offline   Reply With Quote
Old 03-20-2022, 04:10 PM   #15
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: 728
Karma: 228142
Join Date: Sep 2017
Location: Argentina
Device: moon+ reader, kindle paperwhite
They appear to me like this, like the image
The columns I have are:
Status (Read, To Read, Reading)
Title
Author
Date (From Calibre)
Ranking
Tags
Serie
Editorial
Published
Pages
Started (Read start date)
Finished (Date the reading finished)
Days (Number of days to read it)
Attached Thumbnails
Click image for larger version

Name:	1.png
Views:	46
Size:	218.0 KB
ID:	192869  
dunhill is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Result of difference between two dates populated in a column China Diapers Calibre 8 07-07-2019 04:53 AM
Calculate reading time. dunhill Library Management 12 12-12-2018 02:10 PM
How does Kobo calculate reading statistics? Mrs_Often Kobo Reader 24 10-30-2015 03:08 AM
Is there any way to calculate page numbers better for H2O? OrangeFlavored Kobo Reader 3 10-19-2014 06:10 PM


All times are GMT -4. The time now is 11:44 AM.


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