# Assertion without decimals -- How to Remove a decimal value from a String?

**URL:** <https://community.postman.com/t/assertion-without-decimals-how-to-remove-a-decimal-value-from-a-string/42602>\
**Category:** Help Hub\
**Tags:** variables\
**Created:** [January 5, 2023, 4:31am UTC](https://community.postman.com/t/assertion-without-decimals-how-to-remove-a-decimal-value-from-a-string/42602 "2023-01-05T04:31:28Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ahasan386](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@Ahasan386](https://community.postman.com/u/Ahasan386)\
**Post date:** [January 5, 2023, 4:31am UTC](https://community.postman.com/t/assertion-without-decimals-how-to-remove-a-decimal-value-from-a-string/42602/1 "2023-01-05T04:31:28Z")

</div>

How to Remove a decimal value from a String?

var Date\_time = “2023-01-05T03:57:46.4506857+00:00”;

what I want = “2023-01-05T03:57:46+00:00”;

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [January 5, 2023, 12:42pm UTC](https://community.postman.com/t/assertion-without-decimals-how-to-remove-a-decimal-value-from-a-string/42602/2 "2023-01-05T12:42:54Z")

</div>

This can be done using the JavaScript split method.

```auto
let before = "2023-01-05T03:57:46.4506857+00:00";
let after = before.split(".")[0];

console.log(before);
console.log(after);

```

![image](https://us1.discourse-cdn.com/getpostman/original/3X/e/6/e63297bd4ceff7618d41224de55991bb8dafe924.png)

---

<div class="post-metadata">

**Author:** ![Ahasan386](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@Ahasan386](https://community.postman.com/u/Ahasan386)\
**Post date:** [January 5, 2023, 12:54pm UTC](https://community.postman.com/t/assertion-without-decimals-how-to-remove-a-decimal-value-from-a-string/42602/4 "2023-01-05T12:54:19Z")

</div>

Still getting assertion error – AssertionError: expected ‘2023-01-05T03:57:46+00:00’ to deeply equal ‘2023-01-05T03:57:46’

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [January 5, 2023, 1:12pm UTC](https://community.postman.com/t/assertion-without-decimals-how-to-remove-a-decimal-value-from-a-string/42602/5 "2023-01-05T13:12:27Z")

</div>

Can you post your code for the assertion? (please use the preformatted text option in the editor).

---

<div class="post-metadata">

**Author:** ![Ahasan386](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@Ahasan386](https://community.postman.com/u/Ahasan386)\
**Post date:** [January 5, 2023, 1:21pm UTC](https://community.postman.com/t/assertion-without-decimals-how-to-remove-a-decimal-value-from-a-string/42602/6 "2023-01-05T13:21:48Z")

</div>

```auto
let orignal = "2023-01-05T03:57:46.4506857+00:00";
let actual = "2023-01-05T03:57:46+00:00";
let expected = orignal.split(".")[0];

console.log(orignal);
console.log(expected);

pm.test("Validation", function () {
    var jsonData = pm.response.json();
    pm.expect(expected).to.eql(actual);
    

});

```

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [January 5, 2023, 1:30pm UTC](https://community.postman.com/t/assertion-without-decimals-how-to-remove-a-decimal-value-from-a-string/42602/7 "2023-01-05T13:30:30Z")

</div>

This is dirty, there might be a better way using regex.

```auto
let original = "2023-01-05T03:57:46.4506857+00:00";
let actual = "2023-01-05T03:57:46+00:00";
let expected = original.split(".")[0] + "+" + original.split("+")[1];

console.log(original);
console.log(expected);

pm.test("Validation", function () {
    pm.expect(expected).to.eql(actual);
});

```

On a side note, what are you actually trying to assert. Do you really care about the 00:00? You could just use split on the plus sign for the actual as well and that would make both the same format.

Another option is to use something like the moment library (which is included in Postman) to format both dates to yyyymmddhhmmss which means its just a number comparison after that.

---

<div class="post-metadata">

**Author:** ![Ahasan386](https://avatars.discourse-cdn.com/v4/letter/a/258eb7/32.png) [@Ahasan386](https://community.postman.com/u/Ahasan386)\
**Post date:** [January 7, 2023, 4:47am UTC](https://community.postman.com/t/assertion-without-decimals-how-to-remove-a-decimal-value-from-a-string/42602/8 "2023-01-07T04:47:32Z")

</div>

It’s working… thanks
