How do i consider the date before a month

Hi Team,

I want to get a dates like below;
for ex:
now we are in Jan 2023 so i want a date to be selected from Dec 01 2022 to Feb 15 2023…how do i achieve this.
so like if we are in Feb 2023 i need to select a date from Jan 01 2023 till March 15 2023.

Hi @bhanupriya.cb ,

Could you let us know if you need the range from Jan to March or Do you just need the Previous and the next month Dates ?

For Just retrieving the Previous Month and Next Month Dates :

PreviousMonthDate = new DateTime(Now.AddMonths(-1).Year,Now.AddMonths(-1).Month,1)

NextMonthDate = new DateTime(Now.AddMonths(1).Year,Now.AddMonths(1).Month,15)

Let us know if you want to generate all dates between the two dates.

Hi,
Thank you it worked perfect same as i wanted :slight_smile:

1 Like

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