Format Time in DataGrid

C

crjunk

I'm working with a table that has a field that stores time values as a
string. The time values are in military time (such as 13:30).

How can I have 13:30 displayed as 01:30 PM in my datagrid? Can I use
DataFormatString to achieve this?

Thanks,
CR Junk
 
C

crjunk

Elton said:
Try

DataFormatString ={0: HH:mm tt}
or
DataFormatString ={0: hh:mm tt}

Hi Elton,

I tried using both of your suggestions, but they seem to have no effect
on the formatting of the data in the datagrid. Any other suggestions?

Thanks,
CR Junk
 
C

crjunk

Hi Elton,

I forgot to modify my SQL statement:
SELECT CAST(MyTime as DateTime) as MyTime from MyTable.

After adding the Cast/DateTime statement to the MyTime, the
DataFormatString ={0: hh:mm tt} worked when added to the datagrid.

Thanks again!
CR Junk
 
E

Elton Wang

It should be

DataFormatString="{0: hh:mm tt}"

Hi Elton,

I tried using both of your suggestions, but they seem to have no effect
on the formatting of the data in the datagrid. Any other suggestions?

Thanks,
CR Junk
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,562
Members
45,038
Latest member
OrderProperKetocapsules

Latest Threads

Top