473,545 Members | 2,049 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Data Item, "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 2061
RTRIM converts the input param to varchar.
Maybe this is the problem.

"Paul" <do*****@paulNO SPAMMERleblanc. net> wrote in message
news:eh******** *****@tk2msftng p13.phx.gbl...
Hi,
Everything went fine getting a short date format out of SQL into my
DataGrid with this:
<%# DataBinder.Eval (Container.Data Item, "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*****@paulNO SPAMMERleblanc. net> wrote in message
news:eh******** *****@tk2msftng p13.phx.gbl...
Hi,
Everything went fine getting a short date format out of SQL into my
DataGrid with this:
<%# DataBinder.Eval (Container.Data Item, "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
2685
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 does'nt have any time frame Query is shoing only dates; But ASP.NET dategrid showing Time frame also, How can remove the time frame in datagrid
7
1827
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 shows the date and 12:00:00 AM. How do I get rid of the time? My code below. int rowNum = dgDealerInfo.CurrentCell.RowNumber;
2
1448
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
1216
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 started doing a RTRIM(date) when I was retrieving the data. That screwed the pooch big time. Suddenly I lost
5
1302
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
9612
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 '07-Mar-05' the expression {..:dd-MMM-yy} works OK Second question, does anyone know hwo to return a date from SQL server in the format...
5
1556
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 Tuesday afterward, if the last day of the month falls on the week-end and the Monday afterwards is a holiday... to test I set the date to 11/30/2006, to...
1
2374
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. What should I do to let it show time only? Thanks.
5
3151
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 tables in it. One of my forms has two TEXT BOX controls formated as Short Date. The form is binded to a linked table. The linked tables has about 7...
0
7656
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7757
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
5972
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5329
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4945
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3450
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3443
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1014
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
704
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.