- skip to content

# Database Abstraction Layer

### User Tools

- Login

### Site Tools

- Recent changes
- Media Manager
- Sitemap

### Sidebar

##### Resources

- Reference Manual
- User Guide
- The Data Dictionary
- ADOdb-xmlschema
- ADOdb Active Record
- Performance Monitoring
- Date/Time Library
- Session Management Library
- Unsupported Addons
- Coding Standards

##### Supported Databases

- Access
- ADO
- CSV
- Firebird
- Frontbase
- IBM DB2
- Informix
- Interbase
- LDAP
- Microsoft SQL Server
- MySQL
- Netezza
- ODBC
- ODBTP
- Oracle
- PDO
- Postgresql
- SAP ADS
- SAP ASE
- SAP Maxdb
- SAP Sqlanywhere
- Sqlite
- Sybase
- Plain Text
- Visual Foxpro

##### Other

- Feature Comparison Matrix
- Connection Matrix
- Include File Guide

v5:reference:connection:offsetdate

# offsetDate

This function is only available in a limited number of drivers. See the driver documentation for information

##### Syntax

    string offsetDate(
           int $offset
           optional float $baseDate
    )

# Description

The function `offsetDate()` returns a string with the native SQL functions to calculate future and past dates based on `$baseDate` in a portable fashion. If `$baseDate` is not defined, then the current date (at 12 midnight) is used. Returns the SQL string that performs the calculation when passed to Execute().

For example, in Oracle, to find the date and time that is 2.5 days from today, you can use:

    /*
     * get date one week from now
     */

    $fld = $conn->OffsetDate(7);
    /*
     * returns "(trunc(sysdate)+7")
     */

    /*
     *  get date and time that is 60 hours from current date and time
     */

    $fld = $conn->OffsetDate(2.5, $conn->sysTimeStamp);
    /*
     *   returns "(sysdate+2.5)"
     */

    $conn->Execute("UPDATE TABLE SET dodate=$fld WHERE ID=$id");

v5/reference/connection/offsetdate.txt · Last modified: 2016/01/16 16:17 by mnewnham

### Page Tools

- Show pagesource
- Old revisions
- Backlinks
- Rename Page
- Back to top