I have the value as #7/13/2016 3:20:00 PM# And want to separate it out date and time. Format for date is "07/13/2016" and time is "03:20 PM". I have got the values with StartDateTime.ToString("MM/dd/yyyy") and StartDateTime.ToString("HH:mm") but i am not sure about the "AM or PM" thing.
Asked
Active
Viewed 1,269 times
1 Answers
0
If I understand correctly, you have a DateTime value that you are trying to break into separate Date and Time. Microsoft has great documentation on DateTime formatting but I think what you are looking for for your time element is this:
SomeDateTime.ToString("hh:mm tt");
which should output "03:20 PM" or whatever the case may be.

Kevin R.
- 3,571
- 1
- 19
- 29
-
2Actually should use `hh` instead of `HH` as there's no point in having AM/PM with a 24-hour value which is what `HH` does. So `HH:mm tt` would actually output "15:20 PM", not "03:20 PM". – juharr Jul 15 '16 at 18:58
-