final class TimestampCall
    implements Scalar
    uses Snapshot
Public API: explicitly declared with @visibility public.

A call of TIMESTAMPADD(unit, interval, datetime) or TIMESTAMPDIFF(unit, datetime1, datetime2).

Rule: MYSQL-TIMESTAMP-CALL-001. TIMESTAMPADD adds a number of units to its second operand and is typed as a date plus an interval; TIMESTAMPDIFF is the integer number of units from the first to the second operand. The units are the simple units only (interval_time_stamp). The result is NULL when an operand is NULL or invalid. Terminates: the operands are strict parts. Source: https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_timestampadd, https://dev.mysql.com/doc/refman/8.4/en/date-and-time-functions.html#function_timestampdiff. Status: Implemented.

Typing TIMESTAMPDIFF()doctest
$query = (new \SqlSemantics\Platform\MySql\Semantics())->analyze("SELECT TIMESTAMPDIFF(MONTH, '2024-01-01', '2024-03-01')");
    $query->field(0)->type->descriptor->name() // => 'BIGINT'

Properties§

public TimestampOperation $operation
public Scalar $first
public Scalar $second

Methods§

public function __construct(
    public TimestampOperation $operation,
    public IntervalUnit $unit,
    public Scalar $first,
    public Scalar $second,
)

Parameters

$operationTimestampOperationThe function
$unitIntervalUnitThe unit
$firstScalarThe number of units to add, or the start
$secondScalarThe date or time to add to, or the end
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFact

Derives the operands and the result.

Parameters

$derivationDerivation
$environmentEnvironment

Returns

Calls 9
public function render(Output $out): void

Writes the call.

Parameters

$outOutput
Test cases 1
Calls 1

Test cases 4§

Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.

Dedicated tests 3
Other tests reaching this symbol 1

Relations§

Instantiated in 1
Type declarations 1