473,503 Members | 11,783 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Formatting a date in a datagrid

I have a datagrid that has a column that displays a date. The date is
currently being displayed in a long format, I want to format it to display
in short format. How do I do that in a datagrid?
Nov 18 '05 #1
5 1300
Go to the Property Builder (right-click on the datagrid for the context
menu). Assign a column to the date field if you haven't already (don't
autogenerate columns). Pick that column, and assign a format of "{0:d}" to
it.

"William Gower" <w_*****@hotmail.com> wrote in message
news:uN**************@tk2msftngp13.phx.gbl...
I have a datagrid that has a column that displays a date. The date is
currently being displayed in a long format, I want to format it to display
in short format. How do I do that in a datagrid?

Nov 18 '05 #2
Hello William,

<asp:BoundColumn DataField="myField" DataFormatString="{0:D}" />
I have a datagrid that has a column that displays a date. The date is
currently being displayed in a long format, I want to format it to
display in short format. How do I do that in a datagrid?


--
Matt Berther
http://www.mattberther.com
Nov 18 '05 #3
Thanks that got me half way there. It shows now Sunday January 3, 2004. I
want it to show 01/03/2004

"Matt Berther" <mb******@hotmail.com> wrote in message
news:ut**************@tk2msftngp13.phx.gbl...
Hello William,

<asp:BoundColumn DataField="myField" DataFormatString="{0:D}" />
I have a datagrid that has a column that displays a date. The date is
currently being displayed in a long format, I want to format it to
display in short format. How do I do that in a datagrid?


--
Matt Berther
http://www.mattberther.com

Nov 18 '05 #4
Jos
"William Gower" <w_*****@hotmail.com> wrote in message
news:O0**************@TK2MSFTNGP10.phx.gbl...
Thanks that got me half way there. It shows now Sunday January 3, 2004. I want it to show 01/03/2004

"Matt Berther" <mb******@hotmail.com> wrote in message
news:ut**************@tk2msftngp13.phx.gbl...
Hello William,

<asp:BoundColumn DataField="myField" DataFormatString="{0:D}" />
I have a datagrid that has a column that displays a date. The date is
currently being displayed in a long format, I want to format it to
display in short format. How do I do that in a datagrid?


Use a lowercase d instead of uppercase.

--

Jos
Nov 18 '05 #5
Hi
Thanks that got me half way there. It shows now Sunday January 3, 2004. I want it to show 01/03/2004
use the DataFormatString = "{0:MM/dd/yyyy}"

HTH
Regards
Ashish M Bhonkiya

"William Gower" <w_*****@hotmail.com> wrote in message
news:O0**************@TK2MSFTNGP10.phx.gbl... Thanks that got me half way there. It shows now Sunday January 3, 2004. I want it to show 01/03/2004

"Matt Berther" <mb******@hotmail.com> wrote in message
news:ut**************@tk2msftngp13.phx.gbl...
Hello William,

<asp:BoundColumn DataField="myField" DataFormatString="{0:D}" />
I have a datagrid that has a column that displays a date. The date is
currently being displayed in a long format, I want to format it to
display in short format. How do I do that in a datagrid?


--
Matt Berther
http://www.mattberther.com


Nov 18 '05 #6

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

Similar topics

0
972
by: Chumley the Walrus | last post by:
Inside a datagrid that has editcommandcolumns and such, I'm able to format a date variable with DataFormatString ="{0:d}" to display a properly formatted date of 7/14/2004 instead of 7/14/2004...
4
1560
by: Jesper Stocholm | last post by:
I have a WinForm datagrid that receives data from a DataSet. One of the colums is anm INT-column from the database, and I would like to format these INTs before binding them to the control. I...
7
4665
by: Matthew Wieder | last post by:
Hi - I have a datagrid that has a black header and the rows alternate white and gray. The problem is that until items are added to the grid, the grid appears as a large black rectangle, which is...
0
1030
by: Mike Fellows | last post by:
i have a function (shown below) that accepts a web datagrid and populates it with a dataset when i display my datagrid it shows the date as 00/00/0000 00:00:00 i need to format the time from...
5
2730
by: tshad | last post by:
I have been trying to figure out what the Datagrid is doing to create its formatting. I found that some of my Datagrids have a 3D type of border and sometime it has a straight line. I finally...
4
3220
by: hope | last post by:
Hi, How can I format a string field using Data Formatting Expression property in datagrid? For example: format last name from BROWN to Brown. Thanks
5
3929
by: Mike Fellows | last post by:
I have a dataset wich contains 3 columns i wish to format the 3rd column which contains a date field but it shows the date as dd/mm/yyyy 00:00:00 i need to remove the time part of the data (i...
2
1450
by: John Dann | last post by:
I've got what seems to be a common problem with the DataGrid control - I want to display a dataset one of whose columns (always the first column) is a datetime column. But only the date displays...
2
1253
by: psycho | last post by:
in sqlserver in date is stored in a particular format. Date and time are stored in same column. so if i want to display only date or only time in the datagrid is there any solution?
0
7194
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
7070
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
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5566
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,...
1
4993
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...
0
4666
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...
0
3148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1495
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 ...
1
729
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.