Hi Team,
Please help me to achieve this…
String Variable = 1/30/2023, 09:45 AM to Output String Variable = 01/30/2023, 9:45 AM
after comma (,) space is only one time in output variable.
Thanks,
Ritesh
Hi Team,
Please help me to achieve this…
String Variable = 1/30/2023, 09:45 AM to Output String Variable = 01/30/2023, 9:45 AM
after comma (,) space is only one time in output variable.
Thanks,
Ritesh
This is how you can convert
DateTime.ParseEact(InputDate,"M/d/yyyy, hh:mm tt",System.Globalization.CultureInfo.InvariantCulture).ToString("MM/dd/yyyy. h:m tt")
This first one is input format and second one is the output format
Hope this helps
Cheers
Try this ,
String input= “1/30/2023, 09:45 AM”;
DateTime dateTime = DateTime.ParseExact(input, “M/dd/yyyy, hh:mm tt”, CultureInfo.InvariantCulture);
String output = dateTime.ToString(“MM/dd/yyyy, h:mm tt”);
Try this one
DateTime.ParseExact(InputDate,{"M/d/yyyy, hh:mm tt"},System.Globalization.CultureInfo.InvariantCulture,System.Globalization.DateTimeStyles.None).ToString("MM/dd/yyyy. h:m tt")
Regards
Sudharsan
I don’t understand what you want @Ritesh_Burman, i can help you but please explain better the case, what you need ?
Hi @Anil_G ,
Its giving me an Error like String was not recognized as Valid Date Time. What to do?
Regards,
Ritesh
Use your comma as a delimiter first. It’s probably being read as a string because of it.
Then, format your date as a date.
Format your time as a time.
Reassemble your string with the comma.
If there are two spaces then add two spaces…input format should exactly match woth the input value you send as string
I gave based on what you pasted here
Cheers
That Error issue gets resolved now but output is not comming as AM or PM is comming as 01/30/2023, 10:31:00. Please help
Regards,
Ritesh
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.