Java学习者论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

手机号码,快捷登录

恭喜Java学习者论坛(https://www.javaxxz.com)已经为数万Java学习者服务超过8年了!积累会员资料超过10000G+
成为本站VIP会员,下载本站10000G+会员资源,购买链接:点击进入购买VIP会员
JAVA高级面试进阶视频教程Java架构师系统进阶VIP课程

分布式高可用全栈开发微服务教程

Go语言视频零基础入门到精通

Java架构师3期(课件+源码)

Java开发全终端实战租房项目视频教程

SpringBoot2.X入门到高级使用教程

大数据培训第六期全套视频教程

深度学习(CNN RNN GAN)算法原理

Java亿级流量电商系统视频教程

互联网架构师视频教程

年薪50万Spark2.0从入门到精通

年薪50万!人工智能学习路线教程

年薪50万!大数据从入门到精通学习路线年薪50万!机器学习入门到精通视频教程
仿小米商城类app和小程序视频教程深度学习数据分析基础到实战最新黑马javaEE2.1就业课程从 0到JVM实战高手教程 MySQL入门到精通教程
查看: 1101|回复: 0

oracle中round函数对数和日期进行四舍五入

[复制链接]
  • TA的每日心情
    开心
    2021-12-13 21:45
  • 签到天数: 15 天

    [LV.4]偶尔看看III

    发表于 2011-12-30 18:24:59 | 显示全部楼层 |阅读模式
    1 round函数可以用来对数据进行四舍五入,用法如下:

    ROUND( number, decimal_places ),

    number : 需四舍五入处理的数值
    decimal_places : 四舍五入 , 小数取几位 ( 预设为 0 )返回值类型数字例子:
    select round(123.456, 0) from dual; 回传 123
    select round(123.456, 1) from dual; 回传 123.5
    select round(123.456, 2) from dual; 回传 123.46
    select round(123.456, 3) from dual; 回传 123.456
    select round(-123.456, 2) from dual; 回传 -123.46

    2 round用来对日期进行四舍五入,其用法如下:


    In Oracle/PLSQL, the round function returns a date rounded to a specific unit of measure.

    The syntax for the round function is:

    round( date, [ format ] )

    date is the date to round.

    format is the unit of measure to apply for rounding. If the format parameter is omitted, the round function will round to the nearest day.

    Below are the valid format parameters:
    YearSYYYY, YYYY, YEAR, SYEAR, YYY, YY, YRounds up on July 1st
    ISO YearIYYY, IY, I
    QuarterQRounds up on the 16th day of the second month of the quarter
    MonthMONTH, MON, MM, RMRounds up on the 16th day of the month
    WeekWWSame day of the week as the first day of the year
    IWIWSame day of the week as the first day of the ISO year
    WWSame day of the week as the first day of the month
    DayDDD, DD, J
    Start day of the weekDAY, DY, D
    HourHH, HH12, HH24
    MinuteMI


    Applies To:
    Oracle 8i, Oracle 9i, Oracle 10g, Oracle 11g

    For example:

    round(to_date ('22-AUG-03'),'YEAR')would return '01-JAN-04'
    round(to_date ('22-AUG-03'),'Q')would return '01-OCT-03'
    round(to_date ('22-AUG-03'),'MONTH')would return '01-SEP-03'
    round(to_date ('22-AUG-03'),'DDD')would return '22-AUG-03'

    round(to_date ('22-AUG-03'),'DAY')
      
    java学习者论坛:http://www.javaxxz.com

    would return '24-AUG-03'
    回复

    使用道具 举报

    您需要登录后才可以回帖 登录 | 立即注册

    本版积分规则

    QQ|手机版|Java学习者论坛 ( 声明:本站资料整理自互联网,用于Java学习者交流学习使用,对资料版权不负任何法律责任,若有侵权请及时联系客服屏蔽删除 )

    GMT+8, 2024-5-22 01:19 , Processed in 0.351681 second(s), 33 queries .

    Powered by Discuz! X3.4

    © 2001-2017 Comsenz Inc.

    快速回复 返回顶部 返回列表