Handling Dates in SQL Queries
You need to remember two things whenever you specify dates in SQL queries.
- Use yyyy-mm-dd format for dates.
- Insert dates within a pair of hash (#) symbols
[Registry Expiry] > #2014-01-23#
... will list all domains that have a registry expiry after 23rd January 2014.
Custom SQL Date Queries
Watch My Domains ISP supports a few custom SQL queries that may be used to obtain data based on various run-time parameters like the current date or a user selection.
Here are a few examples.
- The [TODAY] parameter will be replaced with the current date.
- [TODAY+30] will be replaced with the date 30 days from today.
- [TODAY-5] will be replaced with the date 5 days prior to today.
[Registry Expiry] < #[TODAY+30]# ORDER BY [Registry Expiry]
The above SQL query will find all domains that will expire before 30 days from the current date.
Empty Date Condition
In some cases you may want to list domains that have an empty date related condition. For example, you may want to list all domains that haven't been looked up at all. In such cases check for NULL dates.
[Lookedup] IS NULL
... will list all domains that have an empty "Lookedup" column.