sql怎麼取時間欄位的年月日的值幻翼高達Zero 2019-06-14

sql取時間欄位中年月日的值的步驟如下:

我們需要準備的材料分別是:電腦、sql查詢器。

1、首先,開啟sql查詢器,連線上相應的sql表。

sql怎麼取時間欄位的年月日的值

2、點選“查詢”按鈕,輸入:SELECT date_format(add_time, ‘%Y’) as year, date_format(add_time, ‘%m’) as month, date_format(add_time, ‘%d’) as day FROM test;。

sql怎麼取時間欄位的年月日的值

3、點選“執行”按鈕,時間欄位的年月日就被取出了。

sql怎麼取時間欄位的年月日的值

sql怎麼取時間欄位的年月日的值owen222777 推薦於2017-11-25

select to_char(時間欄位,‘yyyy-mm-dd’) from 表名;

這樣就取出時間欄位中的年月日 ,格式為 2010-08-19

sql怎麼取時間欄位的年月日的值liuyun0984 2011-08-19

sqlserver裡有內建函式

select DATENAME(year,getdate()) //取年(返回字串)

select DATENAME(month,getdate()) //取月(返回字串)

select DATENAME(day,getdate()) //取日(返回字串)

select DATEPART(year,getdate()) //取年(返回整數)

select DATEPART(month,getdate()) //取月(返回整數)

select DATEPART(day,getdate()) //取日(返回整數)

sql怎麼取時間欄位的年月日的值田響建站 2011-08-19

<%=year(rs(‘’日期‘’))%>-<%=Month(rs(‘’日期‘’))%>-<%=day(rs(‘’日期‘’))%>=年-月-日

sql怎麼取時間欄位的年月日的值雙鵲會 2011-08-19

非常簡單:

select convert(char(10),jf_date,120) from 表名

OK!