Question

I have a gridview column, where I need to display time in format : 3/2/2012 1:22 PM

but my Db saves as 3/2/2012 1:22:42 PM

I want to remove seconds from this text. I can remove it using (MM/DD/YYYY HH:MM:SS) but how do i include the AM/PM from db column ?

Was it helpful?

Solution 2

The format should be ('MM/DD/YYYY HH:MM AM')

OTHER TIPS

If the database provides the date as a DateTime, try to set the DataFormatString property of the GridView column to match your needs. For example

{0:MM/dd/yyyy hh:mm tt}

prints the column like 03/01/2012 03:09 PM .

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top