Solved

Date falls between date range

  • 5 April 2023
  • 6 replies
  • 209 views

Badge +1

HI,

I need to check that the current date is between 2 dates in a last (start date and To date)

I have tried the usual if greater than or equal and less than or equal but nothing works the query always returns no results

Anyone know how to do this?

icon

Best answer by Garrett 5 April 2023, 15:16

View original

6 replies

Userlevel 6
Badge +16

Hi @chrismccarthy1 

 

  1. The 2 dates in the SP List. Confirm that the days are of DateTime type.
  2. Can you post a screenshot of the Query
Userlevel 6
Badge +16

Hi @chrismccarthy1 

Here is an example of comparison. Instead of using dates from the SP List, I will just create variables and set the date values in this example. You should use Dates from the SP columns - however pls verify that DateTime1 <= DateTime2 otherwise the expression will always return False or No

  1. Use a Set Workflow Variable action to create 3 Datetime variables.
    Datetime1 - This is the start Date. 1-Apr
    Datetime2 - This is the end Date. 10-Apr
    DateToday - This is the current Date
  2. Check if DateToday is between Datetime1 and Datetime2.
    Datetime1 <= DateToday <= Datetime2
    Use a Conditional Branch to enter the following expression.

Final Code. 

 

Badge +1

Yes both list columns are DateTime 

 

 

Userlevel 6
Badge +16

Hi @chrismccarthy1 

That works too. Your query expression is correct.

I suspect that perhaps the FromDate is greater than the ToDate
or the dtCurrent date is outside of the FromDate < ToDate range.
Use control values for the Dates. FromDate is 1 Jan 2023, ToDate is 31 Dec 2023. 

Use the Conditional Branch. Place a Log to History at both outcome Yes and No
Use another Log to History to display the values of all 3 dates 

Badge +1

Hi @Garrett 

Thanks for your help all is working as expected.

Cheers 

Userlevel 6
Badge +16

Hey @chrismccarthy1 

Glad to help

Cheers

Reply