ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


Action unknown: siteexport_addpage
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/17 01:17 by mnewnham