Hi Team,

As seen in image, ToDate is my input and i want my from date to be the 1st day of the same month of the ToDate, but in the image we can see that the 23 of the year part is also getting replaced. So what can be a proper solution? Presently i am using .Replace.
Thanks
new DateTime(ToDate.Year, ToDate.Month, 1)
Sorry Peter but my ToDate is also a string variable.
Hi,
How about the following expression?
System.Text.RegularExpressions.Regex.Replace(toDate,"(?<= )\d+(?=,)","1")

Regards,
so you can parse it into a datetime as we do usually with CDate, DateTime.ParseExact, Convert.ToDateTime depending on the given format
e.g.

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