Suggest common day and time constants when a date/datetime field appears as a criteria
When a date or datetime field appears in a WHERE clause, include Suggestions of the following nature and dynamically substitute them upon selection with the nondeterministic or deterministic equivalents:
(I couldn't get my table to format nicely here - please see the copy in the uploaded file.)
(If it's currently 11am on Friday August 20 2021...)
Suggestion Nondeterministic replacement Deterministic replacement
now         GETDATE()                   CAST('11am 20 August 2021' AS DATETIME)
today           CAST(GETDATE() AS DATE)             CAST('20 August 2021' AS DATE)
yesterday       DATEADD(DAY, -1, CAST(GETDATE() AS DATE))   CAST('19 August 2021' AS DATE)
tomorrow        DATEADD(DAY, 1, CAST(GETDATE() AS DATE))    CAST('21 August 2021' AS DATE)
Tuesday         DATEADD(DAY, -3, CAST(GETDATE() AS DATE))   CAST('17 August 2021' AS DATE)
next Thursday       DATEADD(DAY, 6, CAST(GETDATE() AS DATE))    CAST('26 August 2021' AS DATE)
this time last week DATEADD(DAY, -7, GETDATE())         CAST('11am 13 August 2021' AS DATETIME)
midday Wednesday    DATEADD(HOUR,12,DATEDIFF(DAY,2,GETDATE()))  CAST('12pm 25 August 2021' AS DATETIME)
Preferences that could be specified in the Options are:
- Nondeterministic or Deterministic replacements
- Unqualified day names default to past or future
 Wayne Ivory
    
 shared this idea
Wayne Ivory
    
 shared this idea
      
     
        