Link to home
Start Free TrialLog in
Avatar of crescendo
crescendo

asked on

Formatting date/time as AM or PM in a datagrid

My database stores training course dates/times. The courses are only "morning" or "afternoon", so I store 09:00 or 13:00 as the time part. I want to display the date in a datagrid with "AM" or "PM", but not the actual time, e.g

    31/12/2004 PM

How can I do this?
Avatar of surajguptha
surajguptha
Flag of United States of America image

You can format the date after binding it to the datagrid. Check if the time is before 12 or after 12 and manually append an AM or PM to it
ASKER CERTIFIED SOLUTION
Avatar of surajguptha
surajguptha
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of crescendo
crescendo

ASKER

Hi both

Thanks for the suggestions. I don't want to show the time at all, just the AM or PM. I was hoping there was a format parameter that would achieve this (I currently use {0:d}) but I may have to format it manually, as you suggest. Would it be easiest to do it in the ItemDataBound event, server-side?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
In the end, it proved even easier than that! In property builder IO set the format to {0:dd/MM/yy tt} and it worked a treat!

Thanks both.
Absolutely an easiest way! :)

-Nauman.