【发布时间】:2020-08-04 05:03:35
【问题描述】:
我想得到如下的sql日期格式
这是我试过的代码
select case when
left(datepart(day,getdate()),1)=4 then concat(datepart(day,getdate()),'th',' of ',DATENAME(month,GETDATE()),' ',datepart(year,getdate()))
end
这是我 2020 年 8 月 4 日查询的输出
【问题讨论】:
-
尝试在您的报告设计中使用它: = datepart("d",now())&"th of " & MonthName(month(now())) & " " & datepart("YYYY ",现在())
-
6 月 1 日或 8 月 3 日有效。
-
@Ashan 。 . .上标应该在应用层处理。
-
理论上可以编写格式化它的函数,但是一天会有 4 个 case 语句(case 1,21,31 - st, case 2,22 - nd, 3,23 - rd, else - th) 和十个连续字符串
标签: sql sql-server reporting-services