# Obsidian Dataview Query changing meters to time

**URL:** <https://forum.obsidian.md/t/obsidian-dataview-query-changing-meters-to-time/92911>\
**Category:** Help\
**Tags:** dataview\
**Created:** [December 8, 2024, 7:55pm UTC](https://forum.obsidian.md/t/obsidian-dataview-query-changing-meters-to-time/92911 "2024-12-08T19:55:07Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![RankkaApina](https://forum.obsidian.md/user_avatar/forum.obsidian.md/rankkaapina/32/8034_2.png) [@RankkaApina](https://forum.obsidian.md/u/RankkaApina)\
**Post date:** [December 8, 2024, 7:55pm UTC](https://forum.obsidian.md/t/obsidian-dataview-query-changing-meters-to-time/92911/1 "2024-12-08T19:55:08Z")

</div>

### What I’m trying to do

I have a template that I record certain things related to my knitting projects. For yarn, these include among other things (this is how much is in one skein):

```auto
yarn:
  weight: 100g
  length: 400m

```

When I’m making a table of this, with the dataview code:

```dataview
TABLE WITHOUT ID
	link(file.link, file.title) AS "Socks",
	yarn.weight AS "Yarn Weight",
	yarn.length AS "Yarn Length",
	needles.used AS "Needles"
FROM #beta/crafts/knitting/sock-project AND -"z-system"

```

The meters are changed to time: I don’t understand what I’m doing wrong! See below the picture for the result of the above query.

 ![socks2](https://forum.obsidian.md/uploads/default/original/3X/d/6/d61d15206b61bd0187377a09c8168ab4ec9ddf5e.png)

Basically dataview is thinking my 400m(eters) is 400m(minutes), but I don’t understand why…

---

<div class="post-metadata">

**Author:** ![holroy](https://forum.obsidian.md/user_avatar/forum.obsidian.md/holroy/32/77699_2.png) [@holroy](https://forum.obsidian.md/u/holroy)\
**Post date:** [December 8, 2024, 8:17pm UTC](https://forum.obsidian.md/t/obsidian-dataview-query-changing-meters-to-time/92911/2 "2024-12-08T20:17:49Z")

</div>

That’s an unfortunate side effect of _Dataview_ trying to understand durations and dates in your properties. You can circumvent it by using `file.frontmatter.yarn.length`

---

<div class="post-metadata">

**Author:** ![DiCaver](https://forum.obsidian.md/user_avatar/forum.obsidian.md/dicaver/32/70059_2.png) [@DiCaver](https://forum.obsidian.md/u/DiCaver)\
**Post date:** [December 8, 2024, 8:24pm UTC](https://forum.obsidian.md/t/obsidian-dataview-query-changing-meters-to-time/92911/3 "2024-12-08T20:24:27Z")

</div>

Had the same problem and I couldn’t find a solution, so I used `dataviewjs` and pars the numbers.

```javascript
// Function to parse and convert strings like "15,20 km" or "32 m" to numbers
function parseNumber(text) {
    if (!text) return 0;
    // Remove non-numeric characters (except commas and dots), and parse as a number
    let number = parseFloat(String(text).replace(/[^\d,.-]/g, '').replace(',', '.'));
    return isNaN(number) ? 0 : number;
}

```

And than at the bottom when I create a table I call this function:

```javascript
// Render the table with parsed values
dv.table(["Distance", "Ascent"], 
    entries.map(p => [
        parseNumber(p.Distance) + " km", // Parse the Distance and append " km"
        parseNumber(p.Ascent) + " m" // Parse the Ascent and append " m"
    ])

```

Hope this helps you to get going.

Cheers, Marko 🤓

---

<div class="post-metadata">

**Author:** ![RankkaApina](https://forum.obsidian.md/user_avatar/forum.obsidian.md/rankkaapina/32/8034_2.png) [@RankkaApina](https://forum.obsidian.md/u/RankkaApina)\
**Post date:** [December 8, 2024, 8:24pm UTC](https://forum.obsidian.md/t/obsidian-dataview-query-changing-meters-to-time/92911/4 "2024-12-08T20:24:53Z")

</div>

Thanks, this is why I don’t believe in AI, it doesn’t understand me 😂  
I actually circumvented it with using yarn.m instead of yarn.length. Just means that I need to convert to meters if the length is in yards.

---

<div class="post-metadata">

**Author:** ![RankkaApina](https://forum.obsidian.md/user_avatar/forum.obsidian.md/rankkaapina/32/8034_2.png) [@RankkaApina](https://forum.obsidian.md/u/RankkaApina)\
**Post date:** [December 8, 2024, 8:27pm UTC](https://forum.obsidian.md/t/obsidian-dataview-query-changing-meters-to-time/92911/5 "2024-12-08T20:27:10Z")

</div>

I will try this! My circumvention worked (I only had like 3 notes so far, so it wasn’t a lot of work to change), but in general I like solutions that work for more general cases… I had the original idea that I could record the length in meters or in yards, but in general I use meters, so my circumvention is not a bad one…

But this solution might make me learn something 🙂

---

<div class="post-metadata">

**Author:** ![system](https://forum.obsidian.md/uploads/default/original/3X/b/e/bec35fbd23ab28909bb6bfe62cb32eb82dd34019.png) [@system](https://forum.obsidian.md/u/system)\
**Post date:** [March 8, 2025, 8:27pm UTC](https://forum.obsidian.md/t/obsidian-dataview-query-changing-meters-to-time/92911/6 "2025-03-08T20:27:56Z")

</div>

Closed on March 8, 2025, 8:27pm UTC

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