# How to make if compare number of data from java script

**URL:** <https://community.glideapps.com/t/how-to-make-if-compare-number-of-data-from-java-script/71304>\
**Category:** Ask for Help\
**Created:** [March 1, 2024, 4:44am UTC](https://community.glideapps.com/t/how-to-make-if-compare-number-of-data-from-java-script/71304 "2024-03-01T04:44:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nopparat\_Tongsak](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/nopparat_tongsak/32/56202_2.png) [@Nopparat\_Tongsak](https://community.glideapps.com/u/Nopparat_Tongsak)\
**Post date:** [March 1, 2024, 4:44am UTC](https://community.glideapps.com/t/how-to-make-if-compare-number-of-data-from-java-script/71304/1 "2024-03-01T04:44:21Z")

</div>

![2024-03-01_11-39-01](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/0/9/09bf7d2e333b37c683685766f0b4c279596d1301.png)

```auto
// Get the current date
const currentDate = new Date();

// Get the day, month, and year
const day = currentDate.getDate();
const month = currentDate.getMonth() + 1; // Month is zero-indexed, so add 1
const year = currentDate.getFullYear();

// Format the date as needed
const formattedDate = `${year}-${month < 10 ? '0' : ''}${month}-${day < 10 ? '0' : ''}${day}`;

// Print the formatted date
return(day);

```

The outcome i want is to use if compare today date  
if 1-5 day choice1  
if 12 day choice 2  
…

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [March 1, 2024, 5:19am UTC](https://community.glideapps.com/t/how-to-make-if-compare-number-of-data-from-java-script/71304/2 "2024-03-01T05:19:37Z")

</div>

Your JavaScript can be reduced to a single line:

```auto
return new Date().getDate();

```

However, that still won’t help you as the JavaScript column returns a string, which can’t be used in a numerical comparison.

A better approach here is to use a Math column with the following formula: `Day(Now)`, where `Now` is the current date/time. This will return a number, which can be used directly in your if-then-else column.

---

<div class="post-metadata">

**Author:** ![Nopparat\_Tongsak](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/nopparat_tongsak/32/56202_2.png) [@Nopparat\_Tongsak](https://community.glideapps.com/u/Nopparat_Tongsak)\
**Post date:** [March 1, 2024, 8:47am UTC](https://community.glideapps.com/t/how-to-make-if-compare-number-of-data-from-java-script/71304/4 "2024-03-01T08:47:20Z")

</div>

How to get last date of current month? or How many days in current month?  
Also use in if condition.

---

<div class="post-metadata">

**Author:** ![Nataliya\_Kovaleva](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/nataliya_kovaleva/32/67518_2.png) [@Nataliya\_Kovaleva](https://community.glideapps.com/u/Nataliya_Kovaleva)\
**Post date:** [March 1, 2024, 9:38am UTC](https://community.glideapps.com/t/how-to-make-if-compare-number-of-data-from-java-script/71304/5 "2024-03-01T09:38:27Z")

</div>

This post might be helpful [📅 Guide: Mastering Dates & Times](https://community.glideapps.com/t/guide-mastering-dates-times/70381)

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [March 2, 2024, 12:29am UTC](https://community.glideapps.com/t/how-to-make-if-compare-number-of-data-from-java-script/71304/6 "2024-03-02T00:29:34Z")

</div>

> [@Nopparat\_Tongsak](#):
>
> How to get last date of current month? or How many days in current month?

Use this in a math column:

```auto
DAY(N-DAY(N)+15+30-DAY(N-DAY(N)+15+30))

```

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/system/32/53398_2.png) [@system](https://community.glideapps.com/u/system)\
**Post date:** [March 9, 2024, 12:29am UTC](https://community.glideapps.com/t/how-to-make-if-compare-number-of-data-from-java-script/71304/7 "2024-03-09T00:29:49Z")

</div>

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