SQL -> Funkcie -> funkcie pre prácu s dátumom a časom
Prepnúť na rozdelenie podľa funkcií
Funkcia | DB2 | SQLite | MySQL | PostgreSQL | Firebird | OpenLink Virtuoso | Oracle | MSSQL |
---|---|---|---|---|---|---|---|---|
Zvýšenie dátumu | date + arg | N/A | DATE_ADD | arg1 + arg2 | arg1 + arg2 | DATEADD | arg1 + arg2 | DATEADD |
Zníženie dátumu | date - arg | N/A | DATE_SUB | arg1 - arg2 | arg1 - arg2 | DATEDIFF | arg1 - arg2 | DATEDIFF |
Rozdiel dátumov | date1 - date2 | N/A | DATEDIFF | AGE | arg1 - arg2 | DATEDIFF | arg1 - arg2 | DATEDIFF |
Posledný deň mesiaca | date + 1 MONTH - DAY(date) DAYS | N/A | LAST_DAY | N/A | LASTDAYMONTH[1] | N/A | LAST_DAY | N/A |
Time zone konvertcia | N/A | CONVERT_TZ | TIMEZONE | N/A | TIMEZONE | NEW_TIME | N/A | |
Prví nasledující deň v týždni | N/A | N/A | N/A | N/A | NEXT_DAY | N/A | ||
Konvertcia dátumu na text | TO_CHAR(value, format), VARCHAR_FORMAT (value, format) | STRFTIME(format, value) | DATE_FORMAT(value, format) | TO_CHAR(value, format) | CAST(value, datetype), DATETOSTR | CAST | TO_CHAR | DATENAME |
Konvertcia dátumu na číslo | INT(date) | N/A | DATE_PART | EXTRACT | CAST | to_number(to_char()) | DATEPART | |
Konvertcia textu na dátum | DATE(value), TIMESTAMP(value) | N/A | TO_DATE | CAST | STRINGDATE | TO_DATE | CAST | |
Aktuálny dátum | CURRENT_DATE | CURRENT_DATE | CURDATE, CURRENT_DATE | CURRENT_DATE | CURRENT_DATE | CURDATE | SYSDATE | N/A |
Aktuálny čas | CURRENT_TIME | CURRENT_TIME | CURTIME, CURRENT_TIME | CURRENT_TIME | CURRENT_TIME | CURTIME | N/A | N/A |
Aktuálny dátum a čas | current_timestamp | current_timestamp | NOW, current_timestamp | NOW, current_timestamp | current_timestamp, NOW | NOW | SYSTIMESTAMP | GETDATE |