Extracting the correct date

Hi,
i have a scenario where we have a below dates
example:

  1. 10/12/2023 - pending
  2. 10/13/2023 - pending
  3. 10/05/2023 - pending
  4. 10/07/2023 - pending
    Bot will filter the PENDING dates and it has to extract the next pending date but when we use a minimum function we are getting the older date than current date ex: (10/07/2023), so here bot has to consider the current date and extract the next pending date and also it has to extract the pending date if it is on the current date
    please, can u create a workflow and send it … plz

Hi,

Can you share input data type and expected output, if the following sample doesn’t fit for your requirement?

arrStr.Where(Function(s) s.Contains("pending") AndAlso CDate(System.Text.RegularExpressions.Regex.Match(s,"\d{2}/\d{2}/\d{4}").Value)>Now).OrderBy(Function(s) CDate(System.Text.RegularExpressions.Regex.Match(s,"\d{2}/\d{2}/\d{4}").Value)).First()

Sample
Sample20231011-5L.zip (2.4 KB)

Regards,

Hi @Kb_N

Try this

Initialize the following variables:
- CurrentDate (DateTime) = Now
- NextPendingDate (DateTime) = CurrentDate.AddDays(365)  // Initialize with a future date

For Each date in your list:
    If date.Status = "pending":
        If date.Date >= CurrentDate:
            If date.Date < NextPendingDate:
                Assign NextPendingDate = date.Date

Log the value of NextPendingDate (this will be the next pending date considering the current date).

Hope it helps!!

CIV Patient Schedule.xlsx (9.9 KB)

This is the input file
Output has to be … 10/12/2023
Becoz of today date is 10/11/2023
So bot has to be pick the next date… i.e; 10/12/2023

Hi,

How about the following Sample?

DateTime.FromOADate(CDbl(dt.AsEnumerable.Take(dt.Rows.Count-1).Where(Function(r) r("Status").ToString="Pending" AndAlso DateTime.FromOADate(CDbl(r("Date")))>Now).OrderBy(Function(r) DateTime.FromOADate(CDbl(r("Date")))).First().Item("Date"))).ToString("MM/dd/yyyy")

Sample20231011-5Lv2.zip (10.1 KB)

Regards,