Displaying a CAST datetime in RFC822 Format

久未见 提交于 2020-02-05 07:01:08

问题


I would like to display a CAST datetime in an SQL table using the RFC822 format (ex:Fri, 19 Nov 2010 13:43:39) from the following SELECT (part of a larger statement found here)

*_snip_*

,(Select Cast(Cast(FieldValue as nvarchar(max)) as DateTime) 
  from dbo.UserDefinedData where UserDefinedFieldId = 298 
  and UserDefinedRowId = item.UserDefinedRowId) as [pubDate] 

The bit of SQL below will retrieve the current date in the desired format.

How can I integrate it into the above statement (or is there a better way to achieve my goal)?

select left(datename(dw,getdate()),3)+', '+convert(varchar(20),getdate(),113)  

回答1:


,(Select left(datename(dw,cast(fieldvalue as nvarchar(50))),3)+', '+
     convert(varchar(20),cast(fieldvalue as nvarchar(50)),113)
  from dbo.UserDefinedData where UserDefinedFieldId = 298  
  and UserDefinedRowId = item.UserDefinedRowId) as [pubDate]  


来源:https://stackoverflow.com/questions/4228335/displaying-a-cast-datetime-in-rfc822-format

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!