473,396 Members | 1,726 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,396 software developers and data experts.

Date format strings not being applied?

Hi,

Tools and target: VS2005 Pro, SQL server 2000, ASP.NET (GridView).

I am trying to get a date field inside a GridView to display without the
time element.

The date field is coming from a SQL DateTime column.

I have set the
<asp:BoundField DataField="DateClose" DataFormatString="{0:dd/MM/yyyy}"
HeaderText="Close Date" />

I have also tried {0:d} and {0:D} as alternative formats. None seem to
work.

The date is coming out with the time element included, e.g. "01/12/2006
00:00:00", each time.

Any one got an idea why the format string isn't working in this case?

Thanks

Al
Oct 31 '06 #1
3 4052
hi alec.
for some bizarre reason, you have to set HtmlEncode=false on a bound column
in a gridview, to get the DataFormatString to work. loads of people have
complained about this.
hope this helps
Tim

"Alec MacLean" <al**********@NO-SPAM-copeohs.comwrote in message
news:uP**************@TK2MSFTNGP04.phx.gbl...
Hi,

Tools and target: VS2005 Pro, SQL server 2000, ASP.NET (GridView).

I am trying to get a date field inside a GridView to display without the
time element.

The date field is coming from a SQL DateTime column.

I have set the
<asp:BoundField DataField="DateClose" DataFormatString="{0:dd/MM/yyyy}"
HeaderText="Close Date" />

I have also tried {0:d} and {0:D} as alternative formats. None seem to
work.

The date is coming out with the time element included, e.g. "01/12/2006
00:00:00", each time.

Any one got an idea why the format string isn't working in this case?

Thanks

Al

Oct 31 '06 #2
Marvellous - Thank you Tim!!!

A very un-obvious requirement!

Cheers,

Al

"Tim_Mac" <ti********@community.nospamwrote in message
news:%2***************@TK2MSFTNGP03.phx.gbl...
hi alec.
for some bizarre reason, you have to set HtmlEncode=false on a bound
column in a gridview, to get the DataFormatString to work. loads of
people have complained about this.
hope this helps
Tim

"Alec MacLean" <al**********@NO-SPAM-copeohs.comwrote in message
news:uP**************@TK2MSFTNGP04.phx.gbl...
>Hi,

Tools and target: VS2005 Pro, SQL server 2000, ASP.NET (GridView).

I am trying to get a date field inside a GridView to display without the
time element.

The date field is coming from a SQL DateTime column.

I have set the
<asp:BoundField DataField="DateClose" DataFormatString="{0:dd/MM/yyyy}"
HeaderText="Close Date" />

I have also tried {0:d} and {0:D} as alternative formats. None seem to
work.

The date is coming out with the time element included, e.g. "01/12/2006
00:00:00", each time.

Any one got an idea why the format string isn't working in this case?

Thanks

Al


Oct 31 '06 #3
indeed! i posted this solution on my blog last year and it is by far the
most visited article.
cheers

"Alec MacLean" <al**********@NO-SPAM-copeohs.comwrote in message
news:OZ**************@TK2MSFTNGP05.phx.gbl...
Marvellous - Thank you Tim!!!

A very un-obvious requirement!

Cheers,

Al

"Tim_Mac" <ti********@community.nospamwrote in message
news:%2***************@TK2MSFTNGP03.phx.gbl...
>hi alec.
for some bizarre reason, you have to set HtmlEncode=false on a bound
column in a gridview, to get the DataFormatString to work. loads of
people have complained about this.
hope this helps
Tim

"Alec MacLean" <al**********@NO-SPAM-copeohs.comwrote in message
news:uP**************@TK2MSFTNGP04.phx.gbl...
>>Hi,

Tools and target: VS2005 Pro, SQL server 2000, ASP.NET (GridView).

I am trying to get a date field inside a GridView to display without the
time element.

The date field is coming from a SQL DateTime column.

I have set the
<asp:BoundField DataField="DateClose" DataFormatString="{0:dd/MM/yyyy}"
HeaderText="Close Date" />

I have also tried {0:d} and {0:D} as alternative formats. None seem to
work.

The date is coming out with the time element included, e.g. "01/12/2006
00:00:00", each time.

Any one got an idea why the format string isn't working in this case?

Thanks

Al



Oct 31 '06 #4

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

Similar topics

3
by: praba kar | last post by:
Dear All, I have doubt regarding date string to time conversion function. In Python I cannot find flexible date string conversion function like php strtotime. I try to use following type...
15
by: Simon Brooke | last post by:
I'm investigating a bug a customer has reported in our database abstraction layer, and it's making me very unhappy. Brief summary: I have a database abstraction layer which is intended to...
4
by: Tony | last post by:
Hey guys, I use Google Groups quite a bit as it is an enormous wealth of information, and now I need some help. I have created a query using parameters to capture a range of date, the date is...
1
by: Amal Ismail | last post by:
hello i'm inquiring about something .. hope to find help here i'm using ASP.NET Mobile web application using c# And i'm facing a problem , i use SQL server Database I've table inside it a...
8
by: John Wildes | last post by:
Hello all I'm going to try and be brief with my question, please tell me if I have the wrong group. We are querying transaction data from a DB3 database application. The dates are stored as...
15
by: Khurram | last post by:
I have a problem while inserting time value in the datetime Field. I want to Insert only time value in this format (08:15:39) into the SQL Date time Field. I tried to many ways, I can extract...
1
by: scott | last post by:
Hi Everyone, I don't know if this is the correct forum but I thought i'd ask. I have an access DB with a function to automatically safe a table with fields i'm mail merging into MS Word. Word...
20
by: andreas | last post by:
When I copy a vb.net project using date formats from one PC with a windows date format f.e. dd/mm/yyyy to another PC having a format yy/mm/dd then I get errors. How can I change for a while in the...
17
by: pamelafluente | last post by:
Hi I have to insert dates into some Access and SQL Databases. I need to be general as the target computer might be in any country. -------- - For access I wrote the follow: Function...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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...
0
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...

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.