classTimestampCall
final class TimestampCall
implements Scalar
uses Snapshot
@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.
$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 $operationpublic IntervalUnit $unitpublic Scalar $firstpublic Scalar $secondMethods§
public function __construct(
public TimestampOperation $operation,
public IntervalUnit $unit,
public Scalar $first,
public Scalar $second,
)Parameters
$operation | TimestampOperation | The function |
$unit | IntervalUnit | The unit |
$first | Scalar | The number of units to add, or the start |
$second | Scalar | The date or time to add to, or the end |
public function deriveScalar(Derivation $derivation, Environment $environment): ScalarFactDerives the operands and the result.
Parameters
$derivation | Derivation | |
$environment | Environment |
Returns
Calls 9
- method-call Arguments::one() line 57
- new Arguments line 57
- class-const TimestampOperation::Add() line 59
- method-call ResultTyping::dateArithmetic() line 59
- new ResultTyping line 59
- new Known line 59
- class-const TypeClass::Integer() line 59
- new ScalarFact line 61
- class-const Nullability::Nullable() line 61
public function render(Output $out): voidTest cases 4§
Test cases that cover or call this symbol, from the coverage report and from the analyzed test sources.