How to do this

Hi i have date in format of YYYY-MM-DD ex. 2022-04-14
input date to change everytime
what i want to do is i want to find the last day according to input date and then i need to find next month first date

ex. today is april 14 then last day will be 2022-04-30 and first day of next month to be 2022-05-01

i need to use that input date and then find the last day according to the input date and then next month 1st day

Hi @manoj_verma1 ,

Check the Below Expression to get the Last Day of the Month :

Now.AddDays(Math.Abs(Now.Day-DateTime.DaysInMonth(Now.year,Now.Month)))

To get the First Date of the Next Month :

Now.AddDays(Math.Abs(Now.Day-DateTime.DaysInMonth(Now.year,Now.Month))+1)

i need to use that input date and then find the last day according to the input date and then next month 1st day

@manoj_verma1 ,

We would require to Just Substitute the Input Date in Date format in place of Now.

You could Follow the Below Steps :

  1. Create/Assign Input Date as String :
InputDate1 = "2022-03-14"
  1. Convert it to Date format :
InputDate = CDate(InputDate1)
  1. Use the Below Expression to get the Last Date and Next Month Date :
lastDate = InputDate.AddDays(Math.Abs(InputDate.Day-DateTime.DaysInMonth(InputDate.year,InputDate.Month)))
NextMonthFirstDate = InputDate.AddDays(Math.Abs(InputDate.Day-DateTime.DaysInMonth(InputDate.year,InputDate.Month))+1)

Here
InputDate1 - String Type
InputDate - DateTime Type
lastDate - DateTime Type
NextMonthFirstDate - DateTime Type

1 Like

@supermanPunch hi it working great i want the date in format of YYYY-MM-DD
can you please help me with that and also it giving default time that i dont require

@manoj_verma1 , Once you have the two DateTime values, you can Convert it to String format Required with the Expression like the below :

lastDate.ToString("yyyy-MM-dd")

NextMonthFirstDate.ToString("yyyy-MM-dd")
1 Like

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