Using query functions on dates: due_calc < TODAY()

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

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:

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

Error Message

{
  "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?

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:

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:

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

Hope this helps!

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.