在SQL中,使用substring()函數可以對日期和時間字段進行處理。下面是一些示例:
SELECT SUBSTRING(date_column, 1, 4) AS year
FROM table_name;
SELECT SUBSTRING(date_column, 6, 2) AS month
FROM table_name;
SELECT SUBSTRING(date_column, 9, 2) AS day
FROM table_name;
SELECT SUBSTRING(time_column, 1, 2) AS hour
FROM table_name;
SELECT SUBSTRING(time_column, 4, 2) AS minute
FROM table_name;
請根據實際情況調整substring()函數中的參數,以確保正確提取日期和時間字段中的所需部分。