This is my input 01/08/2015 and i want it to look like this 01.08.2015 00:00
Can someone help me I currently have a code I have assigned it to hostDateFrom = DateTime.ParseExact(hostDateFrom.toString(), “MM/dd/yyyy”, Globalization.CultureInfo.InvariantCulture).ToString(“MM.dd.yyyy”)
@Greggy
If you have error like value is not a valid date format something like this
Keep a message box and print the hostDateFrom and check the format there if the format in the expression and the message box differ add the additional format in the expression like
You can simply add the any number of date formats inside the {“”,“”} and the formats should be seperated by comma
The above expression will look into array of string and choose the apt format as per the input string and convert them and return you the output of desired format
You can use DateTime.ParseExact(hostDateFrom.toString(), “MM/dd/yyyy”, Globalization.CultureInfo.InvariantCulture).ToString(“MM.dd.yyyy 00:00”) adding 00:00 will add a static time as you need and also I see you have the value back to hostDateFrom. If hostDateFrom is in Date format than it will fail as the output of right argument is string and you are trying to assign to Date
If you need date than add like this DateTime.ParseExact(DateTime.ParseExact(hostDateFrom.toString(), “MM/dd/yyyy”, Globalization.CultureInfo.InvariantCulture).ToString(“MM.dd.yyyy 00:00”)“MM.dd.yyyy hh:mm”, Globalization.CultureInfo.InvariantCulture)