Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Date format is different in 2 gridviews

Reply
Thread Tools

Date format is different in 2 gridviews

 
 
Hennie
Guest
Posts: n/a
 
      07-11-2006
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


 
Reply With Quote
 
 
 
 
Richard Carpenter
Guest
Posts: n/a
 
      07-11-2006
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


 
Reply With Quote
 
 
 
 
tfsmag
Guest
Posts: n/a
 
      07-11-2006
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


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Date, date date date.... Peter Grison Java 10 05-30-2004 01:20 PM
Date Format - best way of converting a string into a date format Brian Candy ASP .Net 2 02-18-2004 02:13 PM
Given a date, how to find the beginning date and ending date of that week Matt ASP .Net 1 11-08-2003 09:14 PM
Given a date, how to find the beginning date and ending date of that week Matt C Programming 3 11-08-2003 09:07 PM
Given a date, how to find the beginning date and ending date of that week Matt C++ 2 11-08-2003 08:30 PM



Advertisments