[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1095
  • Last Modified:

How to do date arithmetic to return a date as in "select ... from ... where date_field >= [today's date] - 5"

I need to do a query against a Firebird database and haven't seen my exact example.  I want to, in a query, do, "select ... from... where date_field >= [today's date] - 5".    I saw "current_date" in another posting, but I had thought I had to use, "get_date()"  to retrieve the system date?  Appreciate any help.  Susan
0
beechers
Asked:
beechers
1 Solution
 
NickUpsonCommented:
are you working in dialect 1 or 3
0
 
kacorretiredCommented:
SELECT *
      FROM orders
      WHERE  date_field >= ’TODAY’ - 5
0
 
NickUpsonCommented:
kacor's solution will work in dialect 1, dialect 3 will require

select * from employee where finishdate < current_timestamp - 5
0
 
Gary BenadeCommented:
select * from orders where recdate >= current_date - 5

is perfectly valid and returns the current date on the server.

You can also use current_time and current_timestamp
0
 
beechersAuthor Commented:
Thanks to all for your help!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now