Change column of DateTime type to "long date" format

C

Curious

Hi,

I have a column in a grid defined as DateTime type.

Currently, it's displayed in the format of "5/23/2007", for an
example. It seems that it's using the default "short date" format.

I want to use the format of, for an example, "5/23/2007 12:35:58 PM",
to include hour/minute/second. Anyone can advise me on how to change
the format?

Thanks!
 
M

Michael Nemtsev

Hello Curious,

Use DateTime format structures http://msdn2.microsoft.com/en-us/library/8kb3ddd4.aspx
which helps u to set the desired format of dateTime

---
WBR, Michael Nemtsev [.NET/C# MVP].
My blog: http://spaces.live.com/laflour
Team blog: http://devkids.blogspot.com/

"The greatest danger for most of us is not that our aim is too high and we
miss it, but that it is too low and we reach it" (c) Michelangelo

C> Hi,
C>
C> I have a column in a grid defined as DateTime type.
C>
C> Currently, it's displayed in the format of "5/23/2007", for an
C> example. It seems that it's using the default "short date" format.
C>
C> I want to use the format of, for an example, "5/23/2007 12:35:58 PM",
C> to include hour/minute/second. Anyone can advise me on how to change
C> the format?
C>
C> Thanks!
C>
 
C

Curious

Hi Michael,

Thanks for the advice! Let me read the article you sent. If I have
more questions, I'll ask again.

Curious
 
C

Curious

Now after doing some research, I've found out I'll need to add the
following code in a method in order to set the format as "long date":

if (this.gridReports.Cols.Contains("UpdateDate"))
this.gridReports.Cols["UpdateDate"].Format =
"G"; //"G" is long date
if (this.gridReports.Cols.Contains("CreateDate"))
this.gridReports.Cols["CreateDate"].Format = "G";

However, anyone can tell me in which method I should add this? Do I
need other operations such as "UpdateShowing"?

Thanks!
 

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

Top