问题描述
查询如下;
SELECT S.Marks,S.QPName,B.Class,B.BthNo,B。 Batchdate,B.Attender
来自STUDDET S,批次B其中S.BthId = B.BthId和S.StudId ='''252''
当我执行上述查询输出时如下;
标记QPName类BthNo Batchdate Attender
56 REO MFA B12 2011-09-26 00:00:00.000 NIRANJAN
但我希望输出如下;
标记QPName BthNo Batchdate Attender等级
56 REO MFA B12 26- 09-2011 NIRANJAN
i希望以DD-MM-YYYY格式格式化BatchDate。
我怎么能用sql server。
请帮帮我。
问候,
Narasiman P.
Query as follows;
SELECT S.Marks,S.QPName,B.Class,B.BthNo,B.Batchdate,B.Attender
FROM STUDDET S,Batch B where S.BthId = B.BthId and S.StudId = ''252''
when i execute the above query ouput as follows;
Marks QPName Class BthNo Batchdate Attender
56REO MFA B12 2011-09-26 00:00:00.000NIRANJAN
But i want the output as follows;
Marks QPName Class BthNo Batchdate Attender
56REO MFA B12 26-09-2011NIRANJAN
i want to format the BatchDate in the format of DD-MM-YYYY.
for that how can i using sql server.
Please help me.
Regards,
Narasiman P.
推荐答案
SELECT Marks, QPName, Class, BthNo, CONVERT(DATETIME, Batchdate, 105) AS Batchdate, Attender
FROM STUDDET S,Batch B where S.BthId = B.BthId and S.StudId = '252'
基本上,我们正在转换指定世纪的意大利格式(105)。如果你不想要那个世纪,你只需要用5代。
Basically, we are converting the date into Italian format (105) with the century specified. If you didn''t want the century in there, you''d just use 5 instead.
SELECT S.Marks,S.QPName,B.Class,B.BthNo,CONVERT(VARCHAR(10), B.Batchdate, 105) AS B.Batchdate,B.Attender
FROM STUDDET S,Batch B where S.BthId = B.BthId and S.StudId = '252'
这篇关于如何在sql server数据库中以DD-MM-YYYY格式显示日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!