diff options
| author | Mark Newnham <mark@newnhams.com> | 2021-03-24 21:08:18 -0600 |
|---|---|---|
| committer | Damien Regad <dregad@mantisbt.org> | 2021-08-22 11:16:01 +0200 |
| commit | 847f48f0d6e40b9f4f73a9c17c25fa536e437c04 (patch) | |
| tree | 503c8ff6b4a4c1b367f4d68e7cae59e33fa2686e | |
| parent | f29d5f091742c51641d4c875dd1126e6cf521e4c (diff) | |
| download | adodb-847f48f0d6e40b9f4f73a9c17c25fa536e437c04.tar.gz adodb-847f48f0d6e40b9f4f73a9c17c25fa536e437c04.tar.bz2 adodb-847f48f0d6e40b9f4f73a9c17c25fa536e437c04.zip | |
Added The offsetDate() method
| -rw-r--r-- | drivers/adodb-firebird.inc.php | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/adodb-firebird.inc.php b/drivers/adodb-firebird.inc.php index 819e92ae..f0d2c4ee 100644 --- a/drivers/adodb-firebird.inc.php +++ b/drivers/adodb-firebird.inc.php @@ -773,6 +773,25 @@ class ADODB_firebird extends ADOConnection { return $s; } + /** + * Creates a portable date offset field, for use in SQL statements. + * + * @link https://adodb.org/dokuwiki/doku.php?id=v5:reference:connection:offsetdate + * + * @param float $dayFraction A day in floating point + * @param string|bool $date (Optional) The date to offset. If false, uses CURDATE() + * + * @return string + */ + public function offsetDate($dayFraction, $date=false) + { + if (!$date) + $date = $this->sysTimeStamp; + + $fraction = $dayFraction * 24 * 3600; + return sprintf("DATEADD (second, %s, %s) FROM RDB\$DATABASE",$fraction,$date); + } + // Note that Interbase 6.5 uses this ROWS instead - don't you love forking wars! // SELECT col1, col2 FROM table ROWS 5 -- get 5 rows |
