Oracle中關於時間的to_char和to_date

to_char()將時間值轉換爲字符串,to_date()將字符串轉換爲時間


select customer_id,first_name||''||last_name,dob from customers where to_char(dob,'mm')='07';


select customer_id,first_name||''||last_name,dob from customers where to_char(dob,'yyyy')='1958';


select customer_id,first_name||''||last_name,dob from customers where to_char(dob,'yyyy-mm')='1958-04';


select customer_id,first_name||''||last_name,dob from customers where to_char(dob,'yyyy-mm-dd')='1958-04-13';


select customer_id,first_name||''||last_name,dob from customers where to_char(dob,'yyyy-mm-dd')>'1958-04-13';


select customer_id,first_name||''||last_name,dob from customers where dob=to_date('1958-4月-13','yyyy-month-dd');


select customer_id,first_name||''||last_name,dob from customers where dob>to_date('1958-4月-13','yyyy-month-dd');


select customer_id,first_name||''||last_name,dob from customers where dob>to_date('1958-4月','yyyy-month');
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章