我有以下查询检索是我从数据库中需要:如何在SQL Server中使用datetime DateType更改日期的格式?
SELECT
dbo.SafetySuggestionsLog.ID, dbo.SafetySuggestionsLog.Title,
dbo.SafetySuggestionsLog.Description, dbo.employee.Name,
dbo.SafetySuggestionsLog.Username, dbo.Divisions.DivisionShortcut,
dbo.SafetySuggestionsType.Type,
ISNULL(dbo.SafetySuggestionsStatus.Status, '-') AS Status,
dbo.SafetySuggestionsLog.DateSubmitted
FROM
dbo.employee
INNER JOIN
dbo.SafetySuggestionsLog ON dbo.employee.Username = dbo.SafetySuggestionsLog.Username
INNER JOIN
dbo.Divisions ON dbo.employee.DivisionCode = dbo.Divisions.SapCode
INNER JOIN
dbo.SafetySuggestionsType ON dbo.SafetySuggestionsLog.TypeID = dbo.SafetySuggestionsType.ID
LEFT OUTER JOIN
dbo.SafetySuggestionsStatus ON dbo.SafetySuggestionsLog.StatusID = dbo.SafetySuggestionsStatus.ID
ORDER BY
dbo.SafetySuggestionsLog.DateSubmitted DESC
而不是显示为(6/23/2012 7:15:00 AM
)下DateSubmitted
列中的日期,我想它显示为(Jun-2012)
。
如何做到这一点?
为什么你把“2012年6月23日上午07时15分零零秒”在你的查询中?查询应该适用于存储在数据库中的所有日期。 – 2012-07-08 11:50:28
请通过更新的答案.... – 2012-07-08 11:56:07
感谢您的帮助。对此,我真的非常感激。另外,您能否向我解释您在查询中添加的行? – 2012-07-08 12:27:38