eugenezadorin / airtable-php

Simple PHP client for Airtable API
20 stars 7 forks source link

Date format is not working with where method #2

Closed kbtonmoy closed 2 years ago

kbtonmoy commented 2 years ago

I have a column that contains dates but I can't fetch the arrays based on the date format.

$dataFDU = $client->table($tableName) ->select('*') ->where(["Deadline" => "2022-04-02"]) ->execute();

Here is my workaround which returns an empty array. Some help will be appreciated.

eugenezadorin commented 2 years ago

Hi! Sorry for the long wait. Your query actually converts into formula like this: {Deadline}='2022-04-02'.

Looks like Airtable don't support such comparisons and we have to use datetime functions to compare values properly.

I found following workaround for you:

$dataFDU = $client->table($tableName)
    ->select('*')
    ->whereRaw("IS_SAME(Deadline, '2022-04-02')") // using raw formula here
    ->execute();

It's temporary solution, but I will do some research and probably implement something more convenient, like that:

$query->whereDate('Deadline', '2022-04-02');
eugenezadorin commented 2 years ago

Implemented in v0.4.0

Please check out documentation - https://github.com/eugenezadorin/airtable-php#date-filtering