date not datetime in datagrid while reading from db
date not datetime in datagrid while reading from db
am 17.10.2007 21:34:00 von Marcin Wiszowaty
Hello,
I am reading into a dataset through a dataadapter. All drag+drop
implementation. I have a field in the db that is a datetime(8). whenever i
readin this field the datagrid displays the date plus 12:00 am. I want to
get rid of the 12:00am. I am sure that the db does not habe the hour in the
field. .Net is ading it on.
Thank you for your help
Re: date not datetime in datagrid while reading from db
am 18.10.2007 06:16:18 von notmyfirstname
Marcin,
There is only a datetime type in Microsoft software. No DateTime. Even a SQL
shortDate is a DateTime field.
However there is no need to use it. There are plenty of possibilities to
skip the time part.
By instance DateTime.ToDate returns only the date.
Assuming that you are using WindowForms Datagrid (you did not write that)
you can use the columnstyles for that.
Cor
Re: date not datetime in datagrid while reading from db
am 18.10.2007 15:33:18 von Marcin Wiszowaty
Sorry - Im using webforms ASP.net and vo2003
How would i use the DateTime.ToDate or columnstyles. i couldnt find
anything about it in the help.
thank you
"Marcin Wiszowaty" wrote in message
news:uESnaPPEIHA.4028@TK2MSFTNGP05.phx.gbl...
> Hello,
>
> I am reading into a dataset through a dataadapter. All drag+drop
> implementation. I have a field in the db that is a datetime(8). whenever i
> readin this field the datagrid displays the date plus 12:00 am. I want to
> get rid of the 12:00am. I am sure that the db does not habe the hour in
> the field. .Net is ading it on.
>
> Thank you for your help
>
Re: date not datetime in datagrid while reading from db
am 19.10.2007 06:20:17 von notmyfirstname
Marcin,
I always start writing todate while it is date
http://msdn2.microsoft.com/en-us/library/system.datetime.dat e(VS.71).aspx
From a datagrid on a webpage I know not anymore that much that I can help
you with that.
Cor
Re: date not datetime in datagrid while reading from db
am 19.10.2007 08:31:42 von Mansi Shah
Hi,
If you are using stored procedure to get data for dataset, then you can
use 'cast' and 'convert' functions of sql.
you can refer:
http://msdn2.microsoft.com/en-us/library/ms187928.aspx
In short, it would be great if you convert datetime to date before
binding it to grid..
Regards,
Mansi Shah.
*** Sent via Developersdex http://www.developersdex.com ***
Re: date not datetime in datagrid while reading from db
am 19.10.2007 12:11:03 von RAD
On Thu, 18 Oct 2007 23:31:42 -0700, Mansi Shah
wrote:
>Hi,
>
>If you are using stored procedure to get data for dataset, then you can
>use 'cast' and 'convert' functions of sql.
>
>you can refer:
>http://msdn2.microsoft.com/en-us/library/ms187928.aspx
>
>In short, it would be great if you convert datetime to date before
>binding it to grid..
>
>Regards,
>Mansi Shah.
>
>*** Sent via Developersdex http://www.developersdex.com ***
I'm not sure that would solve the problem ... If you create a datetime
object in .NET and only specify the date, the time gets set to
defaults of midnight.
I think the best approach would be to format the gridview to get rid
of the time component
--
http://bytes.thinkersroom.com
Best Solution
am 19.10.2007 15:58:05 von Marcin Wiszowaty
Hello,
the soulution i was looking for was adding
{0:d}
in:
rightclick on the datagrid
chose property builder
--> columns ' from the tabs on left
chose the column from the list on left
add it to the list on rigth
and add the {0:d} to the (data formating expresion) field
thank you for your help
"Marcin Wiszowaty" wrote in message
news:uESnaPPEIHA.4028@TK2MSFTNGP05.phx.gbl...
> Hello,
>
> I am reading into a dataset through a dataadapter. All drag+drop
> implementation. I have a field in the db that is a datetime(8). whenever i
> readin this field the datagrid displays the date plus 12:00 am. I want to
> get rid of the 12:00am. I am sure that the db does not habe the hour in
> the field. .Net is ading it on.
>
> Thank you for your help
>