PHP ORM Where Clause - Date Only, Ignore Time

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • blueprint
    Active Community Member
    • Jan 2019
    • 223

    PHP ORM Where Clause - Date Only, Ignore Time

    How can I filter (using the EspoCRM PHP functions) a date-time field by the date only - ignoring the time part?

    Code:
    $list = $this->getEntityManager()->getRepository($entityType)->where([
    'date(createdAt)' => date("Y-m-d")
    ]);
    The above doesn't seem to work at all.
    Last edited by blueprint; 01-23-2020, 08:08 AM.
  • blueprint
    Active Community Member
    • Jan 2019
    • 223

    #2
    Resolved!

    Use the "LIKE" operator which is "*" in EspoCRM. Thus:

    Code:
    $list = $this->getEntityManager()->getRepository($entityType)->where([
    'createdAt*' => date("Y-m-d %:%:%")
    ]);
    Works just fine.
    Last edited by blueprint; 01-23-2020, 08:08 AM.

    Comment

    • yuri
      Member
      • Mar 2014
      • 8417

      #3
      'DAYOFMONTH:createdAt' => date('Y-m-d')

      If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

      Comment

      Working...