问题
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