function date_sql_pad in Date 5
Same name and namespace in other branches
- 8 date_api/date_api.module \date_sql_pad()
- 6.2 date_api_sql.inc \date_sql_pad()
- 6 date_api_sql.inc \date_sql_pad()
- 7.3 date_api/date_api_sql.inc \date_sql_pad()
- 7 date_api/date_api_sql.inc \date_sql_pad()
- 7.2 date_api/date_api_sql.inc \date_sql_pad()
A helper function to do cross-database padding of date parts
Parameters
$str - a string to apply padding to: @param $size - the size the final string should be @param $pad - the value to pad the string with @param $side - the side of the string to pad
1 call to date_sql_pad()
File
- ./
date.inc, line 2164 - Date/time API functions
Code
function date_sql_pad($str, $size = 2, $pad = '0', $side = 'l') {
switch ($side) {
case 'r':
return "RPAD({$str}, {$size}, '{$pad}')";
default:
return "LPAD({$str}, {$size}, '{$pad}')";
}
}