473,408 Members | 2,813 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,408 software developers and data experts.

Totally weird date format in DataGrid

Hi,
Everything went fine getting a short date format out of SQL into my
DataGrid with this:
<%# DataBinder.Eval(Container.DataItem, "Created", "{0:d}")%>
Then I got too fancy in SQL and started doing a RTRIM(date) when I was
retrieving the data. That screwed the pooch big time. Suddenly I lost
the date formatting and never suspected the dumb RTRIM. After removing
the RTRIM it started working again.

WHA??

I don't even have a clue. How can trimming blank space (that probably
didn't exist anyway) have any effect?
~Paul

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #1
4 1211
RTRIM converts the input param to varchar.
Maybe this is the problem.

"Paul" <do*****@paulNOSPAMMERleblanc.net> wrote in message
news:eh*************@tk2msftngp13.phx.gbl...
Hi,
Everything went fine getting a short date format out of SQL into my
DataGrid with this:
<%# DataBinder.Eval(Container.DataItem, "Created", "{0:d}")%>
Then I got too fancy in SQL and started doing a RTRIM(date) when I was
retrieving the data. That screwed the pooch big time. Suddenly I lost
the date formatting and never suspected the dumb RTRIM. After removing
the RTRIM it started working again.

WHA??

I don't even have a clue. How can trimming blank space (that probably
didn't exist anyway) have any effect?
~Paul

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #2
Paul,
Try changing your formatting on your datagrid's date column to something
like:

{0:dd/MM/yyyy} (- this provides 24/10/2004 UK date format). You can
switch the MM and dd, etc, around as you wish.

If you have unwanted timestamp values appearing after the date, the above
formatting example will stop them appearing. The date from a SQL server
datetime column should not need trimming - you are using a datetime column
and not a varchar column?

Hope that helps.
"Paul" <do*****@paulNOSPAMMERleblanc.net> wrote in message
news:eh*************@tk2msftngp13.phx.gbl...
Hi,
Everything went fine getting a short date format out of SQL into my
DataGrid with this:
<%# DataBinder.Eval(Container.DataItem, "Created", "{0:d}")%>
Then I got too fancy in SQL and started doing a RTRIM(date) when I was
retrieving the data. That screwed the pooch big time. Suddenly I lost
the date formatting and never suspected the dumb RTRIM. After removing
the RTRIM it started working again.

WHA??

I don't even have a clue. How can trimming blank space (that probably
didn't exist anyway) have any effect?
~Paul

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 18 '05 #3
Sharon, that would be a problem (converting a date to VARCHAR!)

Wow, the things I don't know already. :-D

~Paul

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #4
Thanks for the formatting tip, Alec. Yes, I was RTRIM-ing a date column
and that was converting it, I guess, to a VARCHAR. Not exactly what my
DataGrid was expecting, eh?
~Paul

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #5

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

Similar topics

4
by: karunakar | last post by:
Hi All I was poplating Datagrid Datagrid has one of the column showing datetime field format iam showing DATE here not Necessary to populate the Time Frame Even my datebase column also...
7
by: Mike L | last post by:
This is for a Win form. SP sends back the PostMark date to my datagrid, shows proper date in datagrid. When user clicks on datagrid, the code sends the current row to text box. The text box...
2
by: Roger | last post by:
I have a datagrid with a column bound to a date field. Is there a way to format the date field?
4
by: Paul | last post by:
Hi, Everything went fine getting a short date format out of SQL into my DataGrid with this: <%# DataBinder.Eval(Container.DataItem, "Created", "{0:d}")%> Then I got too fancy in SQL and...
5
by: William Gower | last post by:
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?
4
by: yer darn tootin | last post by:
Does anyone know the sort expression for a column that's data has been returned in the format, eg '07 Jul 05'?? The sort expression {..:"dd mmm yy"} doesn't work ( if the column was returned as...
5
by: Coleen | last post by:
Hi all :-) I have a bit of code that chacks for the last day of the Month, and if it falls on a week-end, sets the due date to the Monday after... I'm trying to get the date to go to the...
1
by: Lurc | last post by:
Hi all, One field of Access table is date/time type, and format is long time. In VB.NET, as this table linked to a datagrid, a strange date 12-30-1899 is shown instead of the time expected....
6
by: yoshitha | last post by:
hi db : sql server 2000 lan : C#.net(ASp.Net) in my database table there are 2 fileds of data type datatime. in field 1 i'm storing date in field 2 i'm storing time.
5
by: Easystart | last post by:
Hi, Sorry for my English. English is not my native tougue. I am working in MS Access 2000 with a SQLServer 2000 Backend database. MS Access 2000 is my GUI front end that has SQLServer linked...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.