Displaying total durations of one day/week

I use Coda to keep track of my volunteer hours/time. I have it add the total time I have overall, but want it to display how long I’ve worked today and in the current week.

My current code for the ‘Today’ calculation (keeps outputting 0):

[Calendar View].Duration.SumIF([Calendar View].Start = Today())

And I don’t even know where to start for calculating the total time in the current week! Please help.

Hi @Akansha_Jain and Welcome to the Community :partying_face: !

Maybe this could work :blush: :

[Calendar View].Filter(Start.ToDate() = Today()).Duration.Sum()

Without seeing a dummy doc (or even just a screenshot could help), all I can do is guess (:innocent:) but this should find the rows where Start.ToDate() = Today() in your table [Calendar View] and then sums the corresponding durations :blush:
(Note that Start in the formula is in fact CurrentValue.Start and as I’m also guessing you used a Date/Time format for your Start, the ToDate() is just there to convert the potential Date/Time format to a Date format)

For the total duration for the current week (i.e.: the week containing Today()) you would need to find either the WeekNumber() or the IsoWeekNumber() for each of you Start in your table and then you could compare them to the WeekNumber() (or the IsoWeekNumber()) of Today() with a formula looking like this (see the quick sample down below :innocent: ) :

Table.Filter(IsoWeekNumber = Today().IsoWeekNumber()).Duration.Sum()

Depending where you are, using WeekNumber() or IsoWeekNumber() might have its importance as WeekNumber() will return the number of a week in a year where the 1st week of the year is the week containing the 1st January. It’s also account/doc dependant as it will follow the First day of the week you chose in the doc SettingsRegion :blush:
IsoWeekNumber() on the other hand follows the standard ISO 8601 which always return the number of the week for weeks going from Monday to Sunday (whatever you chose as First day of the week in the doc SettingsRegion) and where the 1st week of the year is the week containing the very 1st Thursday of the year :blush:

Being in EU, I’ve always opted for the IsoWeekNumber() but just in case, in the sample, you’ll find formulas for both IsoWeekNumber() and WeekNumber() :blush:

Don’t hesitate if you have questions or if something’s not clear :blush: … But in the meantime, I hope this helps :innocent:

2 Likes