我正在嘗試更改列名稱GroupingDate的結果視圖中的格式。 當前結果爲2016-01-01 00:00:00
。sql查詢結果中的日期格式
我想看看結果是這樣, 1/1/2016
當前的查詢是
select GroupingDate, SEQ, SentAsReprint
from tproduction
where jobnumber = '111000_01'
我正在嘗試更改列名稱GroupingDate的結果視圖中的格式。 當前結果爲2016-01-01 00:00:00
。sql查詢結果中的日期格式
我想看看結果是這樣, 1/1/2016
當前的查詢是
select GroupingDate, SEQ, SentAsReprint
from tproduction
where jobnumber = '111000_01'
一般來說,這種格式的應該查詢作爲客戶端的外部應用/應用可能有其他顯示器偏好,但是,它是完全可以在SQL中。 Here是一個鏈接。
SQL函數FORMAT可以幫助您執行此操作。
SELECT FORMAT(column_name,"M/D/YYYY") FROM table_name;
如果你正在使用MySQL,也就是
DATE_FORMAT(date,format)
來源:
http://www.w3schools.com/sql/sql_func_format.asp
http://www.w3schools.com/sql/func_date_format.asp
MySQL date format DD/MM/YYYY select query?
正如你感謝@Lamak同樣的答案,你能否標記爲已接受的答案嗎? – Zrechim
格式(GroupingDate, 'M/d/YYYY')作爲[GroupingDate] 這是工作得很好。 謝謝大家。
您可以將結果轉換爲字符串格式。
select CONVERT(VARCHAR(10), GroupingDate, 101), SEQ, SentAsReprint
from tproduction
where jobnumber = '111000_01'
OR
select CONVERT(VARCHAR(10), GroupingDate, 103), SEQ, SentAsReprint
from tproduction
where jobnumber = '111000_01'
我不希望看到在一個月或日0領先。 –
您正在使用哪個'RDBMS'。 –
SQL server 2012 –