Turning a dataviewjs block into an inline query

What I’m trying to do

I’ve got this dataview block:

dv.span( "**RETIREMENT CLOCK:** Only " + Math.floor ((new Date('2027-01-01') - new Date()) / (1000 * 3600)) + " hrs till I'm free!");

It works but it prints on a new line.

What I’d like is an inline query of the form

**RETIREMENT CLOCK:** Only `= some-code` hours till I'm free!

Things I have tried

I’ve tried

`= Math.floor ((new Date('2027-01-01') - new Date()) / (1000 * 3600))`

and various permutations, but I get errors like this:

Getting this going is beyond my current skills.
Can someone please help me figure out the inline query code to get this right?

This seems to work inline (unless I have misunderstood the issue) and exports to PDF without being on a new line. Does it work for you?

Blah, blah, blah. Woof, woof, woof. Wibble, wobble, wabble. **RETIREMENT CLOCK**: _Only `$= dv.span(moment('2027-01-01') .diff(moment(Date()), 'hours') .toLocaleString('en-en') + " hours until I’m free." )`_ Lots of words here and there.

Brilliant! Exactly what I wanted.
Gotta say, though, I find it… irksome that the structure of the inline vs codeblock queries are so different to achieve the same thing.

1 Like