I am currently trying to change the format of a date whilst keeping the times following it. I am currently using DateTime.Now to set a date but it is coming in “mm/dd/yyyy” and the following time. I need it to be “dd/mm/yyyy” and have a time following it. Any ideas how I could achieve this?
I have tried DateTime.Now.ToString(“dd/MM/yyyy”) but I need the times to follow the date to get a total run time.
At the moment, I am getting StartDate and Finish Date from DateTime.Now.ToString(“dd/MM/yyyy hh:mm:ss”). I need to get a total time from subtracting these two variables. I am using @arivu96’s solution:
Which is coming up with an error, screenshotted above
Great
so the expression be like this for different scenarios date_start = Datetime.ParseExact(StartDate.ToString,“dd/MM/yyyy hh:mm:ss”,System.Globalization.CultureInfo.InvariantCulture)