Separate date from Time

Hi ,

I am getting date as 7/30/2022 with Time stamp 00:00:00. Due to some reason split is not working. I just need the date 7/30/2022.

You don’t use split. You use DateTime.ParseExact to turn it into an actual datetime, then get out just the date.

yourDateVar = “7/30/2022 00:00:00”

DateTime.ParseExact(yourDateVar,“M/d/yyyy HH:mm:ss”,System.Globalization.CultureInfo.InvariantCulture).ToString(“M/d/yyyy”)

Hi @marina.dutta
DateVar= “07/30/2022 00:00:00”
dateVariable = DateTime.ParseExact(DateVar, “MM/dd/yyyy H:mm:ss”, System.Globalization.CultureInfo.InvariantCulture).ToString(“MM/dd/yyyy”)

Or

DateVar= “07/30/2022 00:00:00”
dateOnly = DateVar.Substring(0, DateVar.IndexOf(" "))

Hope it helps!!

Hi @marina.dutta

Use this below condition. It might help.

DateVar= “07/30/2022 00:00:00”

DateTime.ParseExact(Datevar, “MM/dd/yyyy H:mm:ss”, System.Globalization.CultureInfo.InvariantCulture).ToString(“MM/dd/yyyy”)

Hope it helps!!
Regards,

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