How to compare the content in a datatable with today's date

hello

Among the dates saved in DT, there are:

  1. October 30 (Wed)
  2. October 31 (Thu)

The variable ‘today’ contains October 31 (Thu).
If either of the dates matches ‘today’, proceed; if neither matches, break

Could you let me know how to do it or provide assistance?

Thank you in advance for your response

@22222222asas

hope they are in same format

dt.AsEnuemrable.Any(function(x) x("DaetColumn").ToString.Equals(TodayVariable))

this give true if atleast one match is found else false

cheers

1 Like

Hi @22222222asas

Here is the solution:
today= DateTime.ParseExact(“10/31/2024”, “MM/dd/yyyy”, System.Globalization.CultureInfo.InvariantCulture)

dt.AsEnumerable().Any(Function(row) DateTime.ParseExact(row(“DateColumnName”).ToString(), “MM/dd/yyyy”, System.Globalization.CultureInfo.InvariantCulture) = today)

This will give you true if date matches with datatable otherwise it will get false
I hope this will solve your issue

Happy Automation

1 Like

@Anil_G

Thank you for your response!
The code works well.
I have one more question: if it’s false, I would like to end the flow. Can you tell me how to do that?

Hi @22222222asas
dtTable.Select(“Convert([Created], ‘System.String’) >= #”+Date.Today.AddDays(-1).ToString +“# AND Convert([Created], ‘System.String’) <= #”+Date.Today.ToString +“#”).Length>0

That will return True or False, between the dates

@Eric_Alvarado

Thank you for your response!
I have one more question: if it’s false, I would like to end the flow. Can you tell me how to do that?

@Akash_Javalekar1
Thank you for your response!
I have one more question: if it’s false, I would like to end the flow. Can you tell me how to do that?

@22222222asas It depends on the process, but you can consider throwing a Business Rule Exception
There’s an activity call ‘Terminate Workflow’ but I’ll recommend you test this many times

1 Like

Hi @22222222asas You can use throw or terminate workflow

1 Like

@22222222asas

terminate workflwo will stop process
or if you want to end some loop then use break

cheers

2 Likes

@Anil_G

Thank you so much for your response!
Thanks to you, I was able to run it successfully. Have a great day!

1 Like

@Eric_Alvarado

Thank you so much for your response! Thanks to you, I was able to run it successfully. Have a great day!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.