您的位置:首页 > 数据库 > Oracle

Oracle中关于时间的to_char和to_date

2013-08-12 21:40 423 查看
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');
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: