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

Datagrid: date_time column only showing date part

P: n/a
Hi,
First my apologies for double-posting but I am not sure wether this is a
VB.Net or TSQL problem.

I have the following problem:
I generate a T-SQL string in order to fill my Dataset and consecuently a
Datagrid.
However on the date_time column only the date part is showing : e.g.
2004-08-14

Instead of the date and the time: e.g. 2004-08-14 02:12:06

The *same* string run at the SQL Server's Query analyzer will give *both*
parts in the date-time column.

TIA for your help
-steve
Nov 21 '05 #1
Share this Question
Share on Google+
4 Replies


P: n/a
oj
Can you show us some vb.net code. It's probably a simple formatting problem
for your datacolumn.

--
-oj
"steve" <st***@here.com> wrote in message
news:9E*******************@weber.videotron.net...
Hi,
First my apologies for double-posting but I am not sure wether this is a
VB.Net or TSQL problem.

I have the following problem:
I generate a T-SQL string in order to fill my Dataset and consecuently a
Datagrid.
However on the date_time column only the date part is showing : e.g.
2004-08-14

Instead of the date and the time: e.g. 2004-08-14 02:12:06

The *same* string run at the SQL Server's Query analyzer will give *both*
parts in the date-time column.

TIA for your help
-steve

Nov 21 '05 #2

P: n/a
Thats probably the cause of the interface ADO.NET, it depends wheter you get
these values and cast it to ^what kind of .NET Type. If you could tell,
that´ll help us in sql server group.

HTH, Jens Suessmeyer.

---
http://www.sqlserver2005.de
---

"steve" <st***@here.com> schrieb im Newsbeitrag
news:9E*******************@weber.videotron.net...
Hi,
First my apologies for double-posting but I am not sure wether this is a
VB.Net or TSQL problem.

I have the following problem:
I generate a T-SQL string in order to fill my Dataset and consecuently a
Datagrid.
However on the date_time column only the date part is showing : e.g.
2004-08-14

Instead of the date and the time: e.g. 2004-08-14 02:12:06

The *same* string run at the SQL Server's Query analyzer will give *both*
parts in the date-time column.

TIA for your help
-steve

Nov 21 '05 #3

P: n/a
thank you OJ and Jens,

As i said I am not very familiar with either SQL Server nor ADO.NET except
the basics.

In the Ent. Manager interface my field is of type smalldatetime.

I cant really show you the code because its quite big and at various places,
however as I said:

1) I construct the SQL query as a sString. (this *same one* I copy and paste
from a textbox into the Query Analyzer and get the datetime *complete* with
the hour part)
2) I create a dataset and then bind it to a datagrid.

Of course the results agree and there is no problem except ... i miss the
hour part in the datagrid!
Maybe I should specify it on the SQL string itself.
BTW, i noticed the when i multiply two real valurs I get some weird result:
e.g. 0.1 X 2.34 = 0.234000005 , is this some kind of internal round off
error from the server? And, what is the simplest way to round values? I
currently use cast( .... as numeric (5,3)).
Is there a simpler way to get two decimals?

TIA again!!!
-steve

"Jens Süßmeyer" <Jens@Remove_this_For_Contacting.sqlserver2005.d e> a écrit
dans le message de news: uh*************@TK2MSFTNGP15.phx.gbl...
Thats probably the cause of the interface ADO.NET, it depends wheter you
get these values and cast it to ^what kind of .NET Type. If you could
tell, that´ll help us in sql server group.

HTH, Jens Suessmeyer.

---
http://www.sqlserver2005.de
---

"steve" <st***@here.com> schrieb im Newsbeitrag
news:9E*******************@weber.videotron.net...
Hi,
First my apologies for double-posting but I am not sure wether this is a
VB.Net or TSQL problem.

I have the following problem:
I generate a T-SQL string in order to fill my Dataset and consecuently a
Datagrid.
However on the date_time column only the date part is showing : e.g.
2004-08-14

Instead of the date and the time: e.g. 2004-08-14 02:12:06

The *same* string run at the SQL Server's Query analyzer will give *both*
parts in the date-time column.

TIA for your help
-steve


Nov 21 '05 #4

P: n/a
oj
Steve,

1. This is by design for datagrid. You want to take a look at this if you
want *custom* formatting.
http://msdn.microsoft.com/library/en...asp?frame=true

2. I get .234 for the result. Perhaps, you want to take a look at formatting
on the UI side.
http://msdn.microsoft.com/library/en...asp?frame=true
--
-oj
"steve" <st***@here.com> wrote in message
news:5K********************@weber.videotron.net...
thank you OJ and Jens,

As i said I am not very familiar with either SQL Server nor ADO.NET except
the basics.

In the Ent. Manager interface my field is of type smalldatetime.

I cant really show you the code because its quite big and at various
places, however as I said:

1) I construct the SQL query as a sString. (this *same one* I copy and
paste from a textbox into the Query Analyzer and get the datetime
*complete* with the hour part)
2) I create a dataset and then bind it to a datagrid.

Of course the results agree and there is no problem except ... i miss the
hour part in the datagrid!
Maybe I should specify it on the SQL string itself.
BTW, i noticed the when i multiply two real valurs I get some weird
result: e.g. 0.1 X 2.34 = 0.234000005 , is this some kind of internal
round off error from the server? And, what is the simplest way to round
values? I currently use cast( .... as numeric (5,3)).
Is there a simpler way to get two decimals?

TIA again!!!
-steve

"Jens Süßmeyer" <Jens@Remove_this_For_Contacting.sqlserver2005.d e> a écrit
dans le message de news: uh*************@TK2MSFTNGP15.phx.gbl...
Thats probably the cause of the interface ADO.NET, it depends wheter you
get these values and cast it to ^what kind of .NET Type. If you could
tell, that´ll help us in sql server group.

HTH, Jens Suessmeyer.

---
http://www.sqlserver2005.de
---

"steve" <st***@here.com> schrieb im Newsbeitrag
news:9E*******************@weber.videotron.net...
Hi,
First my apologies for double-posting but I am not sure wether this is a
VB.Net or TSQL problem.

I have the following problem:
I generate a T-SQL string in order to fill my Dataset and consecuently a
Datagrid.
However on the date_time column only the date part is showing : e.g.
2004-08-14

Instead of the date and the time: e.g. 2004-08-14 02:12:06

The *same* string run at the SQL Server's Query analyzer will give
*both* parts in the date-time column.

TIA for your help
-steve



Nov 21 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.