Date format is different in 2 gridviews

H

Hennie

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
 
R

Richard Carpenter

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
 
T

tfsmag

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top