473,473 Members | 2,282 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Date format is different in 2 gridviews

I have 2 gridviews on a page, each with own SQL Datasource pointing to
different tables on same database.
In the 1st date format is "dd/MM/yyyy"
Other 1
"MM/dd/yyyy hh:mm:ss"

In the SQL database both fields are data type DateTime.
I want both to be in format "dd/MM/yyyy"
Why is the display different, and how can I get them the same?

Thanks
Jul 11 '06 #1
2 1672
I'm not sure why they are displaying differently, but you can Edit
Columns on each and set the format to {0:d} to get the short date
format you want. The only caveat is that you also have to set the
HTMLEncode value to false for the format property to be observed. I've
read that doing so might expose some sort of security risk, but I don't
know the nature or level of severity.

HTH,
Rich

Hennie wrote:
I have 2 gridviews on a page, each with own SQL Datasource pointing to
different tables on same database.
In the 1st date format is "dd/MM/yyyy"
Other 1
"MM/dd/yyyy hh:mm:ss"

In the SQL database both fields are data type DateTime.
I want both to be in format "dd/MM/yyyy"
Why is the display different, and how can I get them the same?

Thanks
Jul 11 '06 #2
You can also specify in your stored proc or ad hoc query how the
database spits out the date format. on the column for the date in the
select clause you can do like so

select
convert(char(10),the_date_field,101) as the_date_field
from tablename

this should format the date as a mm/dd/yyyy
Richard Carpenter wrote:
I'm not sure why they are displaying differently, but you can Edit
Columns on each and set the format to {0:d} to get the short date
format you want. The only caveat is that you also have to set the
HTMLEncode value to false for the format property to be observed. I've
read that doing so might expose some sort of security risk, but I don't
know the nature or level of severity.

HTH,
Rich

Hennie wrote:
I have 2 gridviews on a page, each with own SQL Datasource pointing to
different tables on same database.
In the 1st date format is "dd/MM/yyyy"
Other 1
"MM/dd/yyyy hh:mm:ss"

In the SQL database both fields are data type DateTime.
I want both to be in format "dd/MM/yyyy"
Why is the display different, and how can I get them the same?

Thanks
Jul 11 '06 #3

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

Similar topics

2
by: F | last post by:
Hi All I am facing the most common problem of date where system date is different and SQL server dateformat is different. How I can change Date fomat in SQL server from US to UK format vis...
7
by: vnl | last post by:
I'm trying to run a SQL query but can't find any records when trying to select a certain date. Here's the sql: SELECT field 1, field2, date_and_time, FROM table1 WHERE date_and_time =...
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...
10
by: Jack | last post by:
Hi, I cannot get the date format correctly in dynamic sql statement, after trying various ways of handling it. I need some help with the date format in the following dynamic sql statement. Any...
6
by: Dario Di Bella | last post by:
Hi all, we have the following urgent issue affecting our development team. Initially we had one particular workstation that failed executing queries on a DB2 database, raising an invalid date...
6
by: Willie wjb | last post by:
Hi, i have a client program that sends a filter expression to the server PC. On that server PC this filter is put over a datatable and the result is send back. the server can be located on a...
7
by: Geoff Jones | last post by:
Hi I've just found something very strange when using Date types within string. Consider the following: Dim myDate = DateValueRow("The Date") ' myDate is a date taken from a DataTable '...
1
by: zerbie45 | last post by:
I have a high number of computers that at logon write some information to a sql 2005 database. Information such as computer name, user name, logon date and logon time are entered. Because...
21
by: Darin | last post by:
I have an applicatoin that works 100% perfect when running on a machine setup for English (United States), but when I change it to Spanish (Mexico), the dates start giving me fits. THe reason is...
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
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...
1
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...
0
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,...
0
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
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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...

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.