gpt4 book ai didi

sql - FORMAT([Time], 'hh:mm' ) 返回 NULL

转载 作者:行者123 更新时间:2023-12-05 08:53:14 25 4
gpt4 key购买 nike

我有一个日历表 with the following structure :

CalendarID    nvarchar(13)
Date date
Time time(7)

数据如下:

Calendar table data

将时间列格式化为 hhmm 有效:

SELECT [CalendarID]
, FORMAT([Date], 'ddd, MMM dd, yyyy') AS [DATE]
, FORMAT([Time], 'hhmm') AS [Time]
FROM [dbo].[Calendar]

select time format (hhmm)

但格式化为 hh:mm 不起作用并显示 NULL:

SELECT [CalendarID]
, FORMAT([Date], 'ddd, MMM dd, yyyy') AS [DATE]
, FORMAT([Time], 'hh:mm') AS [Time]
FROM [dbo].[Calendar]

select time format (hh:mm)

如何将其格式化为hh:mm

最佳答案

这样试试:

FORMAT([Time], N'hhmm') AS [Time]

FORMAT([Time], N'hh\:mm') AS [Time]

关于sql - FORMAT([Time], 'hh:mm' ) 返回 NULL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54213258/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com