-2

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.

krunal.cp
  • 93
  • 1
  • 13
  • 2
    If you have a DateTime object, you can use the `TimeOfDay` and `Date` properties to get the time and day parts. – Anon Coward Jul 15 '16 at 18:50

1 Answers1

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
  • 2
    Actually 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
  • @juharr using hh makes sense. Thanks – krunal.cp Jul 15 '16 at 19:06