How to get the dates as per user input in sheet

Hi,
I need help, i want bot to ask for user inputs for start date and end date so based on the input provided by user i need to write the dates in sheet…below is the example

Input dailog box - Start date - 15/01/2022
Input dailog box - End date - 30/01/2022
So if the user input is like this then i want the output as below

15/01/2022
16/01/2022
17/01/2022
18/01/2022
…….
……

30/01/2022

Hi,

Hope the following sample helps you.

sDate = DateTime.ParseExact(sDateStr,"d/M/yyyy",System.Globalization.CultureInfo.InvariantCulture)
eDate = DateTime.ParseExact(eDateStr,"d/M/yyyy",System.Globalization.CultureInfo.InvariantCulture)

arrDate = Enumerable.Range(0,(eDate-sDate).Days+1).Select(Function(i) sDate.AddDays(i)).ToArray()

Sample20220123-1.zip (2.4 KB)

Regards,

Hi,

FYI, If you want to write the result to xlsx sheet, the following will be better.

dt = Enumerable.Range(0,(eDate-sDate).Days+1).Select(Function(i) dt.LoadDataRow({sDate.AddDays(i).ToString("dd/MM/yyyy")},False)).CopyToDataTable()

Sample20220123-1v2.zip (2.8 KB)

Regards,

WOW you are amazing Yoichi, Thank you so much :slight_smile:
The solution is working super fine as I wanted…

1 Like

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