# Removing part of string

**URL:** <https://community.homey.app/t/removing-part-of-string/79756>\
**Category:** Flows\
**Created:** [April 26, 2023, 4:11pm UTC](https://community.homey.app/t/removing-part-of-string/79756 "2023-04-26T16:11:59Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jahn\_K](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jahn_k/32/1150_2.png) [@Jahn\_K](https://community.homey.app/u/Jahn_K)\
**Post date:** [April 26, 2023, 4:11pm UTC](https://community.homey.app/t/removing-part-of-string/79756/1 "2023-04-26T16:11:59Z")

</div>

Hi,  
I need to remove a part of a variable.  
My Bosch washing machine reports remaining time as «160:0».  
I need a flow for removing the «:0»-part and setting this as a number variable.

Any tips? 🙂

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [April 26, 2023, 5:50pm UTC](https://community.homey.app/t/removing-part-of-string/79756/2 "2023-04-26T17:50:17Z")

</div>

This converts the time tag (string), say it is 11:07 AM, into the numeric value 11

![Screenshot from 2023-04-26 19-46-34](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/d/a/da9a9f0f1b360758c513372249a885ad0c792b7c.png)

I’m sure you can do the same with the Bosch variable/tag  
`{{ 0+("<RemainingTimeTag>".split(":")[1]) }}`

You can play with the [1] if the wrong part is omitted before or after the `":"` sign, by using [2] etc.

---

<div class="post-metadata">

**Author:** ![Jahn\_K](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jahn_k/32/1150_2.png) [@Jahn\_K](https://community.homey.app/u/Jahn_K)\
**Post date:** [April 26, 2023, 6:34pm UTC](https://community.homey.app/t/removing-part-of-string/79756/3 "2023-04-26T18:34:31Z")

</div>

Thanks @Peter_Koolen! 😀

---

<div class="post-metadata">

**Author:** ![Jahn\_K](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jahn_k/32/1150_2.png) [@Jahn\_K](https://community.homey.app/u/Jahn_K)\
**Post date:** [April 26, 2023, 6:40pm UTC](https://community.homey.app/t/removing-part-of-string/79756/4 "2023-04-26T18:40:41Z")

</div>

Next question @Peter_Kawa, how can I easily convert a numeric value (160) into a text variable in the format “1 hour and 40 minutes”?

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [April 26, 2023, 7:29pm UTC](https://community.homey.app/t/removing-part-of-string/79756/5 "2023-04-26T19:29:28Z")

</div>

Is it a quiz? 😜  
Oh i’m not mister Koolen 😊 😉

> ![Screenshot from 2023-04-26 21-33-14](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/5/5/5584b527c07443c5734f40540757b6fc4a87450b.png)

Use the following THEN card  
 ![Screenshot from 2023-04-26 21-22-07](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/2/1/212dfe8a694508a7b25e0d09161378b3c68d78f1.png)

Replace the example code at the [Code] part with:

```auto
//Convert number (as argument) to HH:mm

function toHoursAndMinutes(totalMinutes) {
  const hours = Math.floor(totalMinutes / 60);
  const minutes = totalMinutes % 60;

  return `${hours} hour and${minutes > 0 ? ` ${Math.round(minutes)} minutes` : ''}`;
}

// To check the argument value:
console.log("Argument value:", args[0]);

return toHoursAndMinutes(args[0]);

```

Then you’ll get something similar like this, use a numeric variable or tag of your choice (I used just a numeric variable) as argument (=input), connect both cards and use local [Result] string tag in further processing:

 ![Screenshot from 2023-04-26 21-20-30](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/8/7/878062cfd24a80cdad52151816bdb5c4eb32b8f2.png)

The minutes get rounded, to avoid f.i. 45.766666666666 as the minutes number

---

<div class="post-metadata">

**Author:** ![Jahn\_K](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jahn_k/32/1150_2.png) [@Jahn\_K](https://community.homey.app/u/Jahn_K)\
**Post date:** [April 26, 2023, 7:48pm UTC](https://community.homey.app/t/removing-part-of-string/79756/6 "2023-04-26T19:48:39Z")

</div>

Wrong Peter, typed without my glasses 🤓😅  
Yet again: thanks a bunch @Peter_Kawa!! 😀😀

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [April 27, 2023, 2:47pm UTC](https://community.homey.app/t/removing-part-of-string/79756/7 "2023-04-27T14:47:52Z")

</div>

Or you can use the [Better Logic Library](https://homey.app/a/net.i-dev.betterlogic/) expressioncard:  
Place this in the card: `time('H" hours and "m" minutes"', 160*60*1000)` and replace the 160 with the token/tag.

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/f/1/f10fd253e259abf551c69044121ddfac323215e2.png)  
@Peter_Kawa

---

<div class="post-metadata">

**Author:** ![Jahn\_K](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/jahn_k/32/1150_2.png) [@Jahn\_K](https://community.homey.app/u/Jahn_K)\
**Post date:** [May 5, 2023, 3:12pm UTC](https://community.homey.app/t/removing-part-of-string/79756/8 "2023-05-05T15:12:57Z")

</div>

Endes up using this, @Arie_J_Godschalk. 😀  
What If I want to add this value to the current time, and calculste at what time the washing machine is done?

---

<div class="post-metadata">

**Author:** ![Arie\_J\_Godschalk](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/arie_j_godschalk/32/63027_2.png) [@Arie\_J\_Godschalk](https://community.homey.app/u/Arie_J_Godschalk)\
**Post date:** [May 5, 2023, 3:24pm UTC](https://community.homey.app/t/removing-part-of-string/79756/9 "2023-05-05T15:24:09Z")

</div>

At what time (date) in the day you mean?

Here, here you just add your token and multiply it to be milliseconds.  
Then you add the current `Date.now()`, which is the current time in milliseconds.  
The result you put as second parameter to the `date()` function.  
For other formats than `datetime`, like just `time`, see the Better Logic Library App Settings, there are a lot of options and you can create your own custom pre-defined format:

`date('datetime', Date.now() + 160*60*1000)`

 ![image](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/b/b/bb6288bfc8cea7026844137e363a1e02f4aacb9d.png)

---

<div class="post-metadata">

**Author:** ![Bulletcather](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/bulletcather/32/13738_2.png) [@Bulletcather](https://community.homey.app/u/Bulletcather)\
**Post date:** [November 24, 2023, 9:44am UTC](https://community.homey.app/t/removing-part-of-string/79756/10 "2023-11-24T09:44:32Z")

</div>

I’ve been struggling with the following for a while now.

The ANWB route planner app creates travel times as follows: 00:30.

However, if I have this spoken through the Google Speaker, it makes it half past twelve at night.

I would like to remove 00: somehow.

How can I do this.

---

<div class="post-metadata">

**Author:** ![Peter\_Kawa](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/peter_kawa/32/173848_2.png) [@Peter\_Kawa](https://community.homey.app/u/Peter_Kawa)\
**Post date:** [November 25, 2023, 5:32am UTC](https://community.homey.app/t/removing-part-of-string/79756/11 "2023-11-25T05:32:47Z")

</div>

Not BLL, but it works:  
The travel time is available from a tag I presume.

`{{ 0+("[ANWB_tag]".split(":")[2]) }}`

With your example of 00:30, it would be this calculation:  
`{{ 0+("00:30".split(":")[2]) }}`

I tested with the [Time] tag:

 ![Screenshot_20231125-063011_Homey](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/8/a/8ad5514dfea5905e1d993782d25782859aa82ece.jpeg)

You see it only uses the minutes part of the time:

 ![Screenshot_20231125-063140_Homey](https://us1.discourse-cdn.com/flex025/uploads/athom/original/3X/a/0/a0f3e4d7e5f3ede1d9ff02f12a2e3ef9e85ee7d1.jpeg)

---

<div class="post-metadata">

**Author:** ![Bulletcather](https://sea1.discourse-cdn.com/flex025/user_avatar/community.homey.app/bulletcather/32/13738_2.png) [@Bulletcather](https://community.homey.app/u/Bulletcather)\
**Post date:** [November 27, 2023, 10:47am UTC](https://community.homey.app/t/removing-part-of-string/79756/12 "2023-11-27T10:47:58Z")

</div>

> [@Peter\_Kawa](#):
>
> {{ 0+(“[ANWB\_tag]”.split(“:”)[2]) }}

Your the best. This works!!!
