Ingres 中的 DATE_ADD 功能

发布于 2024-08-08 23:13:32 字数 471 浏览 4 评论 0原文

许多(大多数?几乎所有?)SQL 方言都有执行此类功能的方法: date_add( MyDate, MyInterval )

我已经阅读了所有文档,但我在 Ingres 中找不到此功能。我的近期目标是获得“MyDate plus 3 个月”。有谁知道我是否缺少一种简单的方法来做到这一点?

注意:我意识到使用现有的 SQL可能 来实现这一点。但它将涉及:

  • 从我的日期中提取月份
  • 添加 3
  • 从我的日期中提取日期和年份
  • 使用新的日期、月份、年份来创建新日期
  • 但我还需要测试看看我是否跨越了一年边界,所以也会有一个 CASE 语句

对于 Oracle、MySQL、PostgreSQL、SQL Server 以及我能想到的所有其他数据库中如此简单的东西来说,这是非常多的 SQL。这让我充满希望,因为我在某种程度上错过了一个更简单的选择。

Many (most? nearly all?) SQL dialects have a way to perform this type of function:
date_add( MyDate, MyInterval )

I've been through all of the docs, but I cannot find this functionality in Ingres. My immediate goal is to get "MyDate plus 3 months". Does anyone know if there is a simple way to do this that I'm missing?

Note: I realize that it's possible to achieve this with existing SQL. But it will involve:

  • extract the month from my date
  • add 3 to this number
  • extract the day and year from my date
  • use the new day, month, year to create a new date
  • But I also need to test to see if I cross a year boundary, so there will be a CASE statement as well

That's an awful lot of SQL for something that's so simple in Oracle, MySQL, PostgreSQL, SQL Server, and all the others I can think of. It makes me hopeful that I'm somehow missing a much simpler alternative.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

爱的那么颓废 2024-08-15 23:13:32

我手头没有链接。在文档中搜索“日期算术”和/或“间隔”数据类型。

这是一个例子,它与你想要的英语陈述没有什么不同:

DATE('23-oct-09') + '3 months'

I don't have a link to hand. Search your documentation for 'date arithmetic' and/or the 'interval' datatype.

Here's an example, which is not dissimilar to your english statement of what you want:

DATE('23-oct-09') + '3 months'
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文