DB2 common functions

1, char function
char(current date,ISO)——>convert to yyyy-mm-dd
char(current date,USA)——>convert to mm/dd/yyyy
char(current date,EUR)——>convert to dd.mm.yyyy
2. Time
function Given a date, time, or timestamp, use the appropriate function to extract (if applicable) the year, month, day, hour, minute, second, and microsecond components:
YEAR ( current timestamp)
MONTH (current timestamp)
DAY (current timestamp)
HOUR (current timestamp)
MINUTE (current timestamp)
SECOND (current timestamp)
MICROSECOND (current timestamp)

Extract date and time from timestamp alone
DATE (current timestamp)
TIME (current timestamp)

To convert a string to a date or time value, use:
TIMESTAMP ('2002-10-20-12.00.00.000000')
TIMESTAMP ('2002-10-20 12:00:00')
DATE ('2002-10-20 ')
DATE ('10/20/2002')
TIME ('12:00:00')
TIME ('12.00.00')

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325860930&siteId=291194637
db2
db2