Hi All,
I have my date format as str_date =01/31/2025 20:32:25
I want in 1/31/2025
I tried below but getting error.
DateTime.ParseExact(“str_date”, “MM/d/yyyy”, System.Globalization.CultureInfo.InstalledUICulture).ToString(“M/d/yyyy”)
Hi All,
I have my date format as str_date =01/31/2025 20:32:25
I want in 1/31/2025
I tried below but getting error.
DateTime.ParseExact(“str_date”, “MM/d/yyyy”, System.Globalization.CultureInfo.InstalledUICulture).ToString(“M/d/yyyy”)
str_date = "01/31/2025 20:32:25"
Formatted Date: DateTime.ParseExact(str_date.Split(" ").First.Trim(), "MM/d/yyyy", System.Globalization.CultureInfo.InvariantCulture).ToString("M/d/yyyy")
OR
str_date = "01/31/2025 20:32:25"
Formatted Date: DateTime.ParseExact(str_date, "MM/d/yyyy HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture).ToString("M/d/yyyy")
Above both syntaxes will work with your given input.
Hope it helps!!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.