I am reading the value from excel, the data in the excel is in DateTime format
MM/dd/yyyy HH:mm:ss but i want it to be in MM/dd/yyyy in string format.
I am reading the value from excel, the data in the excel is in DateTime format
MM/dd/yyyy HH:mm:ss but i want it to be in MM/dd/yyyy in string format.
Hi @hansen_Lobo
DateTime.ParseExact(Input.ToString,"MM/dd/yyyy hh:mm:ss",System.Globalization.CultureInfo.InvariantCulture).ToString("MM/dd/yyyy")
@hansen_Lobo
Check this below code,
DateTime.ParseExact("10/29/2023 00:00:00","MM/dd/yyyy HH:mm:ss",System.Globalization.CultureInfo.InvariantCulture).ToString("MM/dd/yyyy")
Or
CDate("10/29/2023 00:00:00").ToString("MM/dd/yyyy")
Hope this may help you
What if i want to convert MM/dd/yyyy hh:mm:ss from string format to datetime format?
Then you can use below code,
DateVar(DateTime type) = DateTime.ParseExact("10/29/2023 00:00:00","MM/dd/yyyy HH:mm:ss",System.Globalization.CultureInfo.InvariantCulture)
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.