Get dates till today in a provided format and loop through from that list

Hi all I need the dates from a specific date till today. Like I have a date “2-Jul-23” and I need the dates till today in the same provided format “31-Jul-23” in a list etc. Then I need to loop through this output list from an excel file to find the exact cell value that in which cell the current item of list is placed. The attached excel file is attached for reference.

BroadMoney_M2_Arch.xls (98 KB)

Date format screen shot.

Hi @connect360

Check out the below xaml file it will help you understand better.
Sequence20.xaml (9.8 KB)

Hope it helps!!
Regards,

Hi i need the output of dates in the below format. “31-Jul-23”, because in the attached excel the date format is like “31-Jul-23” . and when i try to search the date in excel, did not find the exact cell value.

Where we can dynamize it by using a variable instead of CDate(…)

e.g.

myStartDate =Cdate("2-Jun-23")
Enumerable.Range(0,(Now.Date - myStartDate ).Days \ 7).Select(Function (x) myStartDate .AddDays(x*7).toString("d-MMM-yy")).toList

@connect360

I have given the same date format i.e dd-MMM-yyyy in the format. Please check once.

Regards

Hello @Parvathy
Can you try this one i got output as like. and your date is column name so you can directly put your code in for each row or something.
image
and your column is date.

note- its not created with best practices. its just for your logic. you can modify as per your conditions all contains default values.
Main.xaml (20.0 KB)
Hope this will solve your issue.
.

Hi its shown an error. also trying to find to import bur not avaiable.

Hi,
Your output date format is like “07/31/2023 00:00:00” but we need the date format like “31-Jul-23” that’s why we cant find the dates in excel.

image

Check and import System.globalization

@connect360

startDate.ToString("dd-MMM-yyyy").Split(" ")(0)

It will print only date in the format dd-MMM-yyyy
Hope it works!!

Error

Below error in your process file.

@connect360

What are you giving in startDate provide the condition. Please check the provided workflow startDate in the workflow is of Datatype: System.Datetime and it will consider the values according to the format dd-MMM-yyyy.

Regards

I am using your provided sequence20. and find the date in excel through loop.

image

image

@connect360

startDate.ToString("dd-MMM-yyyy").Split(" ")(0)

Give this in the message Box inside the while loop.

Regards,

First check the that for each having argument as datacolumn
Second check and import system.globalization

i have done both but still same error.

Then check the variables are proper as per the provided input. out_dt is the datatable which i read from the excel. and remaining variable or you can check that error with the chatgpt may help. cause without full view error and checking i can not solve.

First i have to get the dates till today and then find this list in excel. I have checked all the variables types etc are ok.

@connect360

(From i In Enumerable.Range(0, CInt((currentDate - lastRunDate).TotalDays) + 1) Select lastRunDate.AddDays(i).ToString(“d-MMM-yy”)).ToList()

1 Like