# Using query functions on dates: due\_calc \< TODAY()

**URL:** <https://forum.kintone.dev/t/using-query-functions-on-dates-due-calc-today/1744>\
**Category:** General\
**Tags:** rest-api\
**Created:** [October 29, 2026, 6:27am UTC](https://forum.kintone.dev/t/using-query-functions-on-dates-due-calc-today/1744 "2026-10-29T06:27:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Accelerated-Optics](https://yyz1.discourse-cdn.com/flex035/user_avatar/forum.kintone.dev/accelerated-optics/32/1043_2.png) [@Accelerated-Optics](https://forum.kintone.dev/u/Accelerated-Optics)\
**Post date:** [October 29, 2026, 6:27am UTC](https://forum.kintone.dev/t/using-query-functions-on-dates-due-calc-today/1744/1 "2026-10-29T06:27:56Z")

</div>

**Question / Problem**

Getting `GAIA_IQ04` when using `TODAY()` in a query on a Calculated field. Can functions not be used with Calculated fields?

**Current Situation**

My app has a Date field `start_date` and a Calculated field `due_date` with the formula `start_date + 14 * 24 * 60 * 60` and its display format set to **Date**. On the record list it shows correctly as a date (e.g. 2026-11-12).

I’m building a JS customization that runs on the record list page and fetches all records whose `due_date` has already passed, so I can highlight them.

**Code / Attempts**

```javascript
kintone.events.on('app.record.index.show', async () => {
  const resp = await kintone.api(kintone.api.url('/k/v1/records.json', true), 'GET', {
    app: kintone.app.getId(),
    query: 'due_date < TODAY() order by $id asc limit 500'
  });
  console.log(resp.records);
});

```

I also tried `due_date < FROM_TODAY(0, DAYS)` and `due_date < NOW()`, and got the same error.

If I hard-code a date, it works:

```javascript
query: 'due_date < "2026-10-29" order by $id asc limit 500'

```

**Error Message**

```javascript
{
  "code": "GAIA_IQ04",
  "id": "NNxKi5kzZLyakpqCyIVf",
  "message": "The function TODAY is not available."
}

```

**Desired Outcome / Expected Behavior**

I `due_date < TODAY()` to work the same way it does on a regular Date field, since the Calculated field is formatted as a date. Is there a different way to do this?

---

<div class="post-metadata">

**Author:** ![Danny](https://avatars.discourse-cdn.com/v4/letter/d/848f3c/32.png) [@Danny](https://forum.kintone.dev/u/Danny)\
**Post date:** [October 29, 2026, 7:36pm UTC](https://forum.kintone.dev/t/using-query-functions-on-dates-due-calc-today/1744/2 "2026-10-29T19:36:45Z")

</div>

Hi Accelerated-Optics,

The `GAIA_IQ04` error occurs because query functions such as `TODAY()` are not supported for Calculated fields, even when their display format is set to Date.

Since Kintone stores calculated date values as Unix timestamps (in seconds), you can work around this by generating today's date in JavaScript, converting it to a Unix timestamp, and using that numeric value in your query.

Here's the updated code:

```javascript
kintone.events.on('app.record.index.show', async (event) => {
  const today = new Intl.DateTimeFormat('sv-SE', {
    timeZone: kintone.getLoginUser().timezone
  }).format(new Date());

  const cutoff = Date.parse(`${today}T00:00:00Z`) / 1000;

  const resp = await kintone.api(
    kintone.api.url('/k/v1/records.json', true),
    'GET',
    {
      app: kintone.app.getId(),
      query: `due_date < ${cutoff} order by $id asc limit 500`
    }
  );

  console.log(resp.records);
  return event;
});

```

We tested this with the same Calculated field configuration and successfully retrieved overdue records while excluding future dates.

Your existing field and formula can remain unchanged. You can use the returned records for your highlighting logic.

For reference:

**Kintone Developer – Query String:**

> **[Query string](https://kintone.dev/en/docs/kintone/overview/query-string/)**
>
> Filters multi records from an App by query string.

**Kintone Help – Calculation of Date, Time, and Date and Time:**

> **[Calculation of Date, Time, and Date and time | Kintone Help](https://us.kintone.help/k/en/app/form/autocalc/function/date_time)**
>
> This is the Help for Kintone. This guide describes how to set up and operate Kintone.

Hope this helps!

---

<div class="post-metadata">

**Author:** ![williamwright](https://avatars.discourse-cdn.com/v4/letter/w/3e96dc/32.png) [@williamwright](https://forum.kintone.dev/u/williamwright)\
**Post date:** [November 12, 2026, 6:40pm UTC](https://forum.kintone.dev/t/using-query-functions-on-dates-due-calc-today/1744/3 "2026-11-12T18:40:57Z")

</div>

Since due\_date is just start\_date + 14 days, you can avoid calculated-field query functions entirely by filtering the regular Date field: query: `start_date < FROM_TODAY(-14, DAYS) order by $id asc limit 500`. That matches due\_date \< today (a record due today is not returned) and lets Kintone handle timezone/date boundaries. I’d also be cautious with the timestamp approach: parsing the local date as `T00:00:00Z` can shift the cutoff depending on the user/app timezone.
