public function getSQL(\Parm\DataAccessObjectFactory $factory)
 {
     if ($this->value === null) {
         return $this->field . " " . $this->operator . " NULL";
     } elseif ($this->value instanceof \DateTime) {
         return $this->field . " " . $this->operator . " " . $factory->escapeString($this->value->format($factory->getDateStorageFormat()));
     } elseif (is_numeric($this->value)) {
         $date = new \DateTime();
         $date->setTimestamp((int) $this->value);
         return $this->field . " " . $this->operator . " " . $factory->escapeString($date->format($factory->getDateStorageFormat()));
     } else {
         return $this->field . " " . $this->operator . " " . $factory->escapeString((string) $this->value);
     }
 }
 /**
  * @param $columnName
  * @param  null                   $format
  * @return mixed|string
  * @throws GetFieldValueException
  */
 protected function getDateFieldValue($columnName, $format = null)
 {
     if ($format != null && $this->getFieldValue($columnName) != null) {
         // \Datetime::createFromFormat parses a date value format and sets the time of day to the current system time
         // see http://php.net/manual/en/datetime.createfromformat.php for explanation
         $dateTime = \DateTime::createFromFormat($this->factory->getDateStorageFormat(), $this->getFieldValue($columnName));
         if ($dateTime) {
             // $dateTime will be a new DateTime instance or FALSE on failure.
             // setting the time to midnight as the expected value when pulling from a database
             $dateTime->setTime(0, 0, 0);
             return $dateTime->format($format);
         }
     }
     return $this->getFieldValue($columnName);
 }