【问题标题】:How to convert to_days function from Mysql to Oracle?如何将 to_days 函数从 Mysql 转换为 Oracle?
【发布时间】:2020-03-05 15:25:19
【问题描述】:

我在mysql中使用to_days()函数作为

to_days ( CURRENT_DATE  + interval '1' day )

现在我在 Oracle 数据库上部署相同的查询,但 oracleDB 没有 to_days() 函数。

我能做什么?

【问题讨论】:

    标签: mysql sql oracle date


    【解决方案1】:

    在 MySQL 中,to_days() 计算给定参数与第 0 年 (0000-00-00) 之间的天数。

    等价于:

    to_days(current_date)
    

    应该在 Oracle 中:

    trunc(sysdate) - date '0001-01-01' + 364
    

    截至今天,这两个表达式都返回 737854

    【讨论】:

    • 日期 0000 无效
    • @thatjeffsmith:它似乎适用于 Oracle 11g,但不适用于 18c...我相应地修改了我的答案。
    猜你喜欢
    • 2013-02-07
    • 2015-09-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-09-26
    相关资源
    最近更新 更多