473,656 Members | 2,983 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 1304
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_*****@hotmai l.com> wrote in message
news:uN******** ******@tk2msftn gp13.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:BoundColum n DataField="myFi eld" DataFormatStrin g="{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******@hotma il.com> wrote in message
news:ut******** ******@tk2msftn gp13.phx.gbl...
Hello William,

<asp:BoundColum n DataField="myFi eld" DataFormatStrin g="{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_*****@hotmai l.com> wrote in message
news:O0******** ******@TK2MSFTN GP10.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******@hotma il.com> wrote in message
news:ut******** ******@tk2msftn gp13.phx.gbl...
Hello William,

<asp:BoundColum n DataField="myFi eld" DataFormatStrin g="{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 DataFormatStrin g = "{0:MM/dd/yyyy}"

HTH
Regards
Ashish M Bhonkiya

"William Gower" <w_*****@hotmai l.com> wrote in message
news:O0******** ******@TK2MSFTN GP10.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******@hotma il.com> wrote in message
news:ut******** ******@tk2msftn gp13.phx.gbl...
Hello William,

<asp:BoundColum n DataField="myFi eld" DataFormatStrin g="{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
981
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 12:00AM. But I have a datagrid that just displays data, and when using : <Columns> <asp:BoundColumn DataField="mydate" HeaderText="My Date" DataFormatString ="{0:d}"
4
1571
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 format the grid by applying a style to it, and I have seen in the doc that there on the object DataGridTextBoxColumn is a property called ..Format, that I have a feeling might be usefull to me. I need to prefix the ints with zeros so that the...
7
4670
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 quite ugly. The black area is larger then it is once an item is added. How can I solve this problem either by: A) Having only the header black and the rest of the empty block white or gray (preffered solution) B) Having the color gray or white...
0
1034
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 the end of the date i cant do this in the designer as the webform i use with the datagrid on uses many different functions so i cant format it with the designer
5
2738
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 found that it comes down to whether there is a "rules=all" attribute (which gives me just a thin black line). If that attribute is not there, you get a 3D effect. I haven't yet been able to figure out what causes it. Here is the table def that...
4
3229
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
3932
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 presuming using some sort of format) any help would be greatly appreciated
2
1457
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 not the time. The dataset structure is only defined at runtime so I want to set the format of just this one datetime column programmatically. Would anyone be kind enough to tell me the simplest way of doing so. This is just a detail, albeit an...
2
1262
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
8296
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
8816
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8710
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...
1
8497
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8598
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7310
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...
0
4150
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...
2
1928
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1598
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.