By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,851 Members | 1,022 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,851 IT Pros & Developers. It's quick & easy.

Totally weird date format in DataGrid

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.