473,769 Members | 1,748 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3262
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.gridRepor ts.Cols.Contain s("UpdateDate") )
this.gridReport s.Cols["UpdateDate "].Format =
"G"; //"G" is long date
if (this.gridRepor ts.Cols.Contain s("CreateDate") )
this.gridReport s.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********@yah oo.comwrote in message
news:11******** **************@ o5g2000hsb.goog legroups.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.gridRepor ts.Cols.Contain s("UpdateDate") )
this.gridReport s.Cols["UpdateDate "].Format =
"G"; //"G" is long date
if (this.gridRepor ts.Cols.Contain s("CreateDate") )
this.gridReport s.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
2527
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
2688
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 format to text?
8
4205
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 still is not what I want. What should I do? Thanks..
6
9859
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 date./time formating is : e.g. 2007-10-25 12:45:00 and I would like to transform in using xslt to format : 25-10-2007 12:45:00 does anyone know how to do this ??? thx
2
1850
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 by the user and after entering the date in the textbox (7/5/2007). i want to convert every date into (MM/DD/YYYY) i:e (5/7/2007) and insert it into ms access. after that while getting back the date to the aspx page for viewing i want to convert...
2
2217
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
4587
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, from the spreadsheet I have an append query that appends only certain fields from the spreadsheet to a table. One of the fields is called . The date in this field are displayed as ‘yyyymmdd’ ex:20070525 To change date format I usually create an...
3
5320
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 the table. How can i do this............ Thanks in Advance.
0
2687
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 to type in the date in mysql format to update or insert new records, I want to force the datagridview to display the date column in mysql format for consistency. Heres my code for that: dataGridView1.DataSource = loadData();
0
9423
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10047
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8872
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7410
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6674
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5304
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3962
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3563
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.