Separate Time hours minute and AM

Hi,

I want to separate the value like this
InputString = “07:00 am”

And i need output is
Hours = 07
Minutes = 00
Am/pm = AM

Anyone can help for the same

Thanks in advance :slight_smile:

Regards,
Shriharsha H N

2 Likes

Hi,

Hope the following helps you.

text = "07:00 am"

strHour = text.Split({":"c," "c})(0)
strMinute = text.Split({":"c," "c})(1)
strAMPM = text.Split({":"c," "c})(2)

OR

strHour = DateTime.Parse(text).ToString("hh")
strMinute = DateTime.Parse(text).ToString("mm")
strAMPM = DateTime.Parse(text).ToString("tt")

Regards,

3 Likes

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