[研究]SQL Server 2019 T-SQL 取得 ISO 8601標準之日期時間
2023-01-06
環境:Visual Studio 2022 + ASP.NET + WebForm + Web Application + C#
********************************************************************************
根據
CAST 和 CONVERT (Transact-SQL) - SQL Server | Microsoft Learn
https://learn.microsoft.com/zh-tw/sql/t-sql/functions/cast-and-convert-transact-sql?view=sql-server-ver16
23 ISO8601 yyyy-mm-dd
126 ISO8601 yyyy-mm-ddThh:mi:ss.mmm (沒有空格)
127 具有時區 Z 的 ISO8601 yyyy-MM-ddThh:mm:ss.fffZ (沒有空格)
T-SQL 寫法 (官方範例)
SELECT GETDATE() AS UnconvertedDateTime, CAST(GETDATE() AS NVARCHAR(30)) AS UsingCast, CONVERT(NVARCHAR(30), GETDATE(), 126) AS UsingConvertTo_ISO8601; SELECT '2006-04-25T15:50:59.997' AS UnconvertedText, CAST('2006-04-25T15:50:59.997' AS DATETIME) AS UsingCast, CONVERT(DATETIME, '2006-04-25T15:50:59.997', 126) AS UsingConvertFrom_ISO8601; |
(完)
相關
ISO 8601
https://www.iso.org/search.html?q=8601
ISO 8601 - 維基百科,自由的百科全書
https://zh.wikipedia.org/zh-tw/ISO_8601
ISO 8601 - Wikiwand
https://www.wikiwand.com/zh-hk/ISO_8601
CAST 和 CONVERT (Transact-SQL) - SQL Server | Microsoft Learn
https://learn.microsoft.com/zh-tw/sql/t-sql/functions/cast-and-convert-transact-sql?view=sql-server-ver16
CAST and CONVERT (Transact-SQL) - SQL Server | Microsoft Learn
https://learn.microsoft.com/en-us/sql/t-sql/functions/cast-and-convert-transact-sql?view=sql-server-ver16
日期與時間資料類型與函數 - SQL Server (Transact-SQL) | Microsoft Learn
https://learn.microsoft.com/zh-tw/sql/t-sql/functions/date-and-time-data-types-and-functions-transact-sql?view=sql-server-ver16
Date and Time Data Types and Functions - SQL Server (Transact-SQL) | Microsoft Learn
https://learn.microsoft.com/en-us/sql/t-sql/functions/date-and-time-data-types-and-functions-transact-sql?view=sql-server-ver16
德瑞克:SQL Server 學習筆記: SQL Server:認識日期時間的分隔符號;搭配使用 SET DATEFORMAT、SET LANGUAGE
http://sharedderrick.blogspot.com/2012/06/t-sql-set-dateformatset-language.html
沒有留言:
張貼留言