Limiting Results with a time window

Hello all,

I am pretty new to TOAD so forgive me for basic questions/followups. I am using it for some scheduling. I currently have a bunch of entities that are tied to some maintenance actions. These actions are on a rotating schedule, and I was hoping to make a query which would provide me with what ever actions are due the current day for the entities I am looking at.

I have successfully used the query builder to provide me with a table that gives me
| Entity | Planned start date of action | Action name |

However, this provides me with all of the planned actions for all of the future, and I am trying to figure out how to get the results to just display the current days results.

I have tried using trunc(date) to different extents in my query editor but it seems to always break the query builder and not give the results that I am looking for. I was hoping someone could guide me and tell me what I am likely doing wrong, if I am able to edit the code like that, and what to do to get it to provide what I am looking for. Ive googled around but been unsuccessful.

Let me know if I need to provide more context or info, thank you for any help!

Welcome to the Toad Data Point forum, btw.

Just a general comment: fiddling with date data types can be tricky in any RDBMS. That said, it would be great to have a lot more context here... e.g. which database platform you're working with, example SQL code and function calls you're trying to execute, etc.

That said, most databases have function calls or reserved key words that represent the current date (and time). For example, in SQL Server, you can invoke NOW() or GETDATE(), to name a few methods.
For Oracle, you can use SYSDATE or CURRENT_DATE.

Hope this gets you started.

1 Like

It's kind of important to know which database type you are working with. e.g. Oracle? SQL Server?
The Properties pane for the connector you're using should tell you a lot. Once you know the database platform, then you can find out which function calls or reserved words return the current date. Then, you can add a phrase in your WHERE clause to make sure your column date values equal the current date.
e.g.
... WHERE
AND PLANNED_START_DATE = CURRENT_DATE()
(or whatever function returns the current date...)

Also, the query that the Visual Query builder creates for you is editable, although the most common workflow is to use one of the tool bar buttons (or right-click option) to get the built query into the Editor. That way, you can play around with the query syntax in the Editor without messing up your query definition in the Query Builder.

1 Like