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

date not datetime in datagrid while reading from db

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
Oct 17 '07 #1
6 1649
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

Oct 18 '07 #2
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" <mw********@finmedsys.comwrote in message
news:uE**************@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

Oct 18 '07 #3
Marcin,

I always start writing todate while it is date

http://msdn2.microsoft.com/en-us/lib...te(VS.71).aspx

From a datagrid on a webpage I know not anymore that much that I can help
you with that.

Cor

Oct 19 '07 #4
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 ***
Oct 19 '07 #5
On Thu, 18 Oct 2007 23:31:42 -0700, Mansi Shah <ma***@devdex.com>
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
Oct 19 '07 #6
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" <mw********@finmedsys.comwrote in message
news:uE**************@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

Oct 19 '07 #7

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

Similar topics

8
by: Gerrit Holl | last post by:
Posted with permission from the author. I have some comments on this PEP, see the (coming) followup to this message. PEP: 321 Title: Date/Time Parsing and Formatting Version: $Revision: 1.3 $...
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...
3
by: Jim H | last post by:
I have a DataGrid where the DataSource is a DataTable that has a DateTime column. Right now it only shows the Date, I want the date and time down to the seconds or better. How do I set the...
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...
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...
9
by: Shapper | last post by:
Hello, I created a dataset from a XML file. One of the dataset fields is . In an ASP:Repeater I am displaying the field. <%# DataBinder.Eval(Container.DataItem, "pubDate", "{0:f}") %> The...
12
by: Rob T | last post by:
I'm storing a date/time into a SQL table of type datetime. I need it to be precise so the value is stored to the 1000th of a second. ie "insert into myTable mydate values ('08/05/2005...
1
by: harsha reddy | last post by:
Dear All, I have a front end form which has a couple of dropdown menus which select data from the database based on the value selected, the stored procedure which the program accesses outputs...
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.
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
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...

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.