2 回答
TA貢獻1797條經(jīng)驗 獲得超6個贊
oracle里沒有convert函數(shù),varchar2轉(zhuǎn)date類型的話用to_date函數(shù),date類型轉(zhuǎn)字符串用to_char函數(shù)。
to_date(String, 格式),返回值是date類型
to_char(Date, 格式),返回值是字符串
格式:
Year:
yy two digits 兩位年 顯示值:07
yyy three digits 三位年 顯示值:007
yyyy four digits 四位年 顯示值:2007
Month:
mm number 兩位月 顯示值:11
mon abbreviated 字符集表示 顯示值:11月,若是英文版,顯示nov
month spelled out 字符集表示 顯示值:11月,若是英文版,顯示november
Day:
dd number 當月第幾天 顯示值:02
ddd number 當年第幾天 顯示值:02
dy abbreviated 當周第幾天簡寫 顯示值:星期五,若是英文版,顯示fri
day spelled out 當周第幾天全寫 顯示值:星期五,若是英文版,顯示friday
ddspth spelled out, ordinal twelfth
Hour:
hh two digits 12小時進制 顯示值:01
hh24 two digits 24小時進制 顯示值:13
Minute:
mi two digits 60進制 顯示值:45
Second:
ss two digits 60進制 顯示值:25
其它
Q digit 季度 顯示值:4
WW digit 當年第幾周 顯示值:44
W digit 當月第幾周 顯示值:1
24小時格式下時間范圍為: 0:00:00 - 23:59:59....
12小時格式下時間范圍為: 1:00:00 - 12:59:59 ....
1. 日期和字符轉(zhuǎn)換函數(shù)用法(to_date,to_char)
select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') as nowTime from dual; //日期轉(zhuǎn)化為字符串
select to_char(sysdate,'yyyy') as nowYear from dual; //獲取時間的年
select to_char(sysdate,'mm') as nowMonth from dual; //獲取時間的月
select to_char(sysdate,'dd') as nowDay from dual; //獲取時間的日
select to_char(sysdate,'hh24') as nowHour from dual; //獲取時間的時
select to_char(sysdate,'mi') as nowMinute from dual; //獲取時間的分
select to_char(sysdate,'ss') as nowSecond from dual; //獲取時間的秒
select to_date('2004-05-07 13:23:44','yyyy-mm-dd hh24:mi:ss') from dual//
TA貢獻1862條經(jīng)驗 獲得超7個贊
select Nvl(Sum(Nvl(ReceiveWeight, 0)), 0) ReceiveWeight
from t_Measure
where To_Char(MeasureDateTime, 'yyyy-mm-dd') <= '" + txtDates.Text.Trim() + "'
添加回答
舉報
