假设 SQL Server:
DECLARE @string VARCHAR(17) = '20120301-20120331';
SELECT
CONVERT(DATETIME, LEFT(@string, 8)),
CONVERT(DATETIME, RIGHT(@string, 8));
从表中:
SELECT
CONVERT(DATETIME, LEFT(column_name, 8)),
CONVERT(DATETIME, RIGHT(column_name, 8))
FROM dbo.table_name;