public function SqlsrvDateSql::getDateField in Drupal driver for SQL Server and SQL Azure 8
Same name and namespace in other branches
- 4.2.x src/Plugin/views/query/SqlsrvDateSql.php \Drupal\sqlsrv\Plugin\views\query\SqlsrvDateSql::getDateField()
- 3.0.x src/Plugin/views/query/SqlsrvDateSql.php \Drupal\sqlsrv\Plugin\views\query\SqlsrvDateSql::getDateField()
- 3.1.x src/Plugin/views/query/SqlsrvDateSql.php \Drupal\sqlsrv\Plugin\views\query\SqlsrvDateSql::getDateField()
- 4.0.x src/Plugin/views/query/SqlsrvDateSql.php \Drupal\sqlsrv\Plugin\views\query\SqlsrvDateSql::getDateField()
- 4.1.x src/Plugin/views/query/SqlsrvDateSql.php \Drupal\sqlsrv\Plugin\views\query\SqlsrvDateSql::getDateField()
Returns a native database expression for a given field.
Parameters
string $field: The query field that will be used in the expression.
bool $string_date: For certain databases, date format functions vary depending on string or numeric storage.
Return value
string An expression representing a date field with timezone.
Overrides DateSqlInterface::getDateField
File
- src/
Plugin/ views/ query/ SqlsrvDateSql.php, line 61
Class
- SqlsrvDateSql
- MSSQL-specific date handling.
Namespace
Drupal\sqlsrv\Plugin\views\queryCode
public function getDateField($field, $string_date) {
if ($string_date) {
return "CONVERT(datetime2, {$field}, 127)";
}
// Base date field storage is timestamp, so the date to be returned here is
// epoch + stored value (seconds from epoch).
return "DATEADD(second, {$field}, '19700101')";
}