為什麼在sql sever中使用format對文字格式化,提

時間 2022-01-06 13:05:02

1樓:匿名使用者

format在sql server上不能用,sql server上規範日期格式是用convert(),format在access中能用。

2樓:匿名使用者

select 0 as id , convert(varchar(30), getdate(), 0 ) as result union all

select 100 as id , convert(varchar(30), getdate(), 100) as result union all

select 1 as id , convert(varchar(30), getdate(), 1 ) as result union all

select 101 as id , convert(varchar(30), getdate(), 101) as result union all

select 2 as id , convert(varchar(30), getdate(), 2 ) as result union all

select 102 as id , convert(varchar(30), getdate(), 102) as result union all

select 2 as id , convert(varchar(30), getdate(), 2 ) as result union all

select 102 as id , convert(varchar(30), getdate(), 102) as result union all

select 3 as id , convert(varchar(30), getdate(), 3 ) as result union all

select 103 as id , convert(varchar(30), getdate(), 103) as result union all

select 4 as id , convert(varchar(30), getdate(), 4 ) as result union all

select 104 as id , convert(varchar(30), getdate(), 104) as result union all

select 5 as id , convert(varchar(30), getdate(), 5 ) as result union all

select 105 as id , convert(varchar(30), getdate(), 105) as result union all

select 6 as id , convert(varchar(30), getdate(), 6 ) as result union all

select 106 as id , convert(varchar(30), getdate(), 106) as result union all

select 7 as id , convert(varchar(30), getdate(), 7 ) as result union all

select 107 as id , convert(varchar(30), getdate(), 107) as result union all

select 8 as id , convert(varchar(30), getdate(), 8 ) as result union all

select 108 as id , convert(varchar(30), getdate(), 108) as result union all

select 9 as id , convert(varchar(30), getdate(), 9 ) as result union all

select 109 as id , convert(varchar(30), getdate(), 109) as result union all

select 10 as id , convert(varchar(30), getdate(), 10 ) as result union all

select 110 as id , convert(varchar(30), getdate(), 110) as result union all

select 11 as id , convert(varchar(30), getdate(), 11 ) as result union all

select 111 as id , convert(varchar(30), getdate(), 111) as result union all

select 12 as id , convert(varchar(30), getdate(), 12 ) as result union all

select 112 as id , convert(varchar(30), getdate(), 112) as result union all

select 13 as id , convert(varchar(30), getdate(), 13 ) as result union all

select 113 as id , convert(varchar(30), getdate(), 113) as result union all

select 14 as id , convert(varchar(30), getdate(), 14 ) as result union all

select 114 as id , convert(varchar(30), getdate(), 114) as result union all

select 20 as id , convert(varchar(30), getdate(), 20 ) as result union all

select 120 as id , convert(varchar(30), getdate(), 120) as result union all

select 21 as id , convert(varchar(30), getdate(), 21 ) as result union all

select 121 as id , convert(varchar(30), getdate(), 121) as result

sql server 裡面執行一下, 看看你需要哪一種格式。

3樓:匿名使用者

select productname, unitprice,

convert(varchar,getdate(),23) as perdate

from products

4樓:d調的聰

select productname, unitprice, format(getdate(),'yyyy-mm-dd') as perdate from products

改為select productname, unitprice, convert(date, getdate()) as perdate from products

5樓:樂視大波浪

張嘴就來,什麼叫做不能用?半罐水響叮噹的典型代表

在sql sever中,mid函式用於從文字欄位中提取字元, 為什麼會提示「'mid' 不是可以識別的 內建函式名稱。

6樓:匿名使用者

好像 sql server 裡面,  沒有  mid  這個函式啊。

substring 倒是可以完成你需要的功能。

select

substring('abcdefg', 2, 3) a,substring('一二三四五六七', 2, 3) b,substring(n'abcdefg', 2, 3) na,substring(n'一二三四五六七', 2, 3) nb;

a      b      na  nb

bcd    二三四    bcd 二三四(1 行受影響)

為什麼在會計軟體中使用GL,FA之類的字母代表總賬,固定資

實力派晨哥 在會計軟體中使用gl,fa之類的字母代表總賬,固定資產,這些都是對應科目的英文縮寫,便於記錄和查詢gl 總賬 general ledge 固定資產 fixed asset 總賬是指總分類賬簿也稱總分類賬。是根據總分類科目開設賬戶,用來登記全部經濟業務,進行總分類核算,提供總括核算資料的分...

怎麼在LabVIEW中使用Modbus通訊

情談學長 1.開啟tia portal程式設計軟體,建立新專案,新增新裝置,並注意必須正確選擇裝置型號和版本。3.開啟main塊並將通訊命令 other modbus tcp mb server功能塊拖入程式。系統將提示建立後臺資料塊。將功能塊的connect id引腳更改為非零值。4.功能塊的mb...

怎麼在ecel中使用lookup函式

輕煙談生活 在excel中使用lookup函式的具體操作步驟如下 1 首先我們開啟電腦上的excel軟體開啟如圖所示的 要在資訊表中找出指定員工的部門,而且查詢方式為從右向左。2 我們用到函式lookup,常規用法 lookup 1,0 條件區域 指定條件 要返回的區域 3 我們在要存放的單元格里輸...