public function SqlsrvDateSql::getDateFormat in Drupal driver for SQL Server and SQL Azure 4.2.x
Same name and namespace in other branches
- 8 src/Plugin/views/query/SqlsrvDateSql.php \Drupal\sqlsrv\Plugin\views\query\SqlsrvDateSql::getDateFormat()
- 3.0.x src/Plugin/views/query/SqlsrvDateSql.php \Drupal\sqlsrv\Plugin\views\query\SqlsrvDateSql::getDateFormat()
- 3.1.x src/Plugin/views/query/SqlsrvDateSql.php \Drupal\sqlsrv\Plugin\views\query\SqlsrvDateSql::getDateFormat()
- 4.0.x src/Plugin/views/query/SqlsrvDateSql.php \Drupal\sqlsrv\Plugin\views\query\SqlsrvDateSql::getDateFormat()
- 4.1.x src/Plugin/views/query/SqlsrvDateSql.php \Drupal\sqlsrv\Plugin\views\query\SqlsrvDateSql::getDateFormat()
Creates a native database date formatting.
Parameters
string $field: An appropriate query expression pointing to the date field.
string $format: A format string for the result. For example: 'Y-m-d H:i:s'.
Return value
string A string representing the field formatted as a date as specified by $format.
Overrides DateSqlInterface::getDateFormat
File
- src/
Plugin/ views/ query/ SqlsrvDateSql.php, line 74
Class
- SqlsrvDateSql
- MSSQL-specific date handling.
Namespace
Drupal\sqlsrv\Plugin\views\queryCode
public function getDateFormat($field, $format) {
$format = strtr($format, static::$replace);
if ($format === 'W') {
return "DATEPART(iso_week, {$field})";
}
return "FORMAT({$field}, '{$format}')";
}