Trying to calculate percentage of completion of quarter based on date in filename

What I’m trying to do

I am trying to calculate the percentage of the completion of the quarter based on the date in the filename of my daily page (YYYY-MM-DD).

Things I have tried

I have used this working code:

`$= Math.round((("now").toFormat("ooo") -"now").startOf("quarter").toFormat("ooo") + 1) / ("now").endOf("quarter").toFormat("ooo") -"now").startOf("quarter").toFormat("ooo") + 1))*100) + " %"` 

and tried to rewrite it so that not the current date, but the date in the filename of the (daily) page is used:

`$= const d = dv.current(); 
const itq = dv.span(parseInt(d.toFormat("ooo")) - parseInt(d.startOf("quarter").toFormat("ooo")) + 1);
const eoq = dv.span(parseInt(d.endOf("quarter").toFormat("ooo")) - parseInt(d.startOf("quarter").toFormat("ooo")) + 1); 
Math.round((itq / eoq)*100) + " %"` 

When you’re in an inline query you need to use something like dv.span() or dv.paragraph() (or some other of the render functions ) to display the end result.

Utilising this new information, you can see that you need to remove the two you’ve used, and add it to that last statement. So presented one multiple lines, but you need to concatenate it onto one line:

`$= const d = dv.current(); 
const itq = parseInt(d.toFormat("ooo")) - parseInt(d.startOf("quarter").toFormat("ooo")) + 1;
const eoq = parseInt(d.endOf("quarter").toFormat("ooo")) - parseInt(d.startOf("quarter").toFormat("ooo")) + 1; 
dv.span(Math.round((itq / eoq)*100) + " %") `
1 Like

Fantastic! Thank you for all your support!!

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.