473,395 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Change column of DateTime type to "long date" format

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!

May 25 '07 #1
4 3237
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

CHi,
C>
CI have a column in a grid defined as DateTime type.
C>
CCurrently, it's displayed in the format of "5/23/2007", for an
Cexample. It seems that it's using the default "short date" format.
C>
CI want to use the format of, for an example, "5/23/2007 12:35:58 PM",
Cto include hour/minute/second. Anyone can advise me on how to change
Cthe format?
C>
CThanks!
C>
May 25 '07 #2
Hi Michael,

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

Curious

May 25 '07 #3
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!

May 27 '07 #4
I believe you need to handle in grid only 2 events - CellFormatting and
CellParsing.
"Curious" <fi********@yahoo.comwrote in message
news:11**********************@o5g2000hsb.googlegro ups.com...
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!


May 27 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Miso Hlavac | last post by:
hello, I need to change date format from mm.dd.yyyy to dd.mm.yyyy But only for one database. In other databases I need mm.dd.yyyy is it possible set this format permanently??? thanx... miso
2
by: Shapper | last post by:
Hello, I have this code line: <%# DataBinder.Eval(Container.DataItem, "publication_date") %> Which displays the date and time as follows: 02-04-2005 0:00:00 How can I change the date...
8
by: berry | last post by:
Hi all, How to change a date format? Example: 6/5/2007 I want to change to 5 June 2007. I get the date from the calendar. I had change the dateformat in the properties already. But the result...
6
by: nataria | last post by:
Hi, I have a problem in transforming date format. Originally I transform an access database data into XML then transform the XML doc into another XML with different strucutre. The original...
2
by: siva33 | last post by:
i am getting problem with the date. i will explain my problem detailed. plz solve for me, plzzz send me the code if possible aspx file and aspx.vb file i have taken a text box to enter the date...
2
by: mrteno | last post by:
I'm using mysql, and used field with DATE type the default date format in my database is yyyy/mm/dd how to change the date format to dd/mm/yyyy
3
by: Bface | last post by:
Hi all, Hope everyone had a good holiday. I am having a difficult time changing the date format of a field from Excel. I have never had this problem before. I link the excel spreadsheet to my DB,...
3
by: Limno | last post by:
Hi, Can anyone suggest me, how to change the Date format in SQL. By Default it Creates datatype datetime as '0000-00-00 00:00:00'. But i want to change d format as Month/Date/Year. while Creating...
0
by: modolamara | last post by:
Hi people, im importing a date column from a mysql database to a datagridview but it automatically changes the date format from 'YYYY-MM-DD' (Mysql format) to 'MM/DD/YYYY' since the user has...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.