473,753 Members | 7,743 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

no millisecond from Sqldatetime to System.Datetime

1 New Member
Hi to all,
I have a trouble with datetime...now I explain..
I must to store to a C# variable the values from a "Datetime column" of Sql Server 2005.
I tried 3 methods ...in the first two I never was able to get the Millisecond from datacolumn.
I explain the methods...

1) I created a Datatable that contain the column... then I fill a datarow with the current value. The system automatically
converts the Sqldatetime in System.Datetime but it isn't able to memorize the millisecond.
In sql table they are 807 but in datarow the are equal to zero.

Then...
2) I used this lines..
SqlDataReader reader = command.Execute Reader();
while(reader.Re ad() == true)
{
SqlDatetime p=reader.GetDat eTime(0);
}

but The system cut again the milliseconds...
Then i Thought that it's a trouble about the convertion beetwen SqlDatetime--->System.Datetim e so i tried that:

3)SqlDataReader reader = command.Execute Reader();
while(reader.Re ad() == true)
{
SqlDatetime p=reader.GetSql DateTime(0);
}
now it work well!!!! The milliseconds are valorized correctly...

Now the questions :)
1)My theretical question : for me it's absurd that System.Datetime not store the milliseconds from sql because
in the System.Datetime the Time values are measured in 100-nanosecond units while the Sqldatetime has an accuracy
of 3.33 milliseconds... I suppose that system.Datetime would contain the millisecond values of SqlDatetime without problems...

2)My Pratical Question: I need to use a Datarow because the table has many columns... but I can't because the
system converts automatically the Sqldatetime (from the Datetime Column) in System.Datetime and not memorize the milliseconds for that column...
Any ideas for that?
Thank you very much.
Oct 29 '09 #1
0 2823

Sign in to post your reply or Sign up for a free account.

Similar topics

1
6309
by: sgh | last post by:
Why doesn't this date time pattern support milliseconds? That makes it hard for me to map my date, time, and dateTime XML schema types to System.DateTime values without losing millisecond precision. The DateTime.ToString("u") format specifier chops off the milliseconds of my values :( Anybody got a work-around for this?
2
2624
by: damon.f | last post by:
I've got a classic ASP application that I'm migrating to .NET. In the client script we used to use the following code to help build up the sql string. It converted a text date to the SQL Server Date format. sSQL = sSQL + SQLServerDate(Request.Form ("PLANNEDEXITDATE")) + "," I'm now trying to do this server side in VB.NET but I can't seem to find a way to do it using convert or
1
1377
by: poppy | last post by:
I set up my parameters in code as follows : lTTState.startDate = Today.AddDays(-10) lTTState.startDate = Today lSqlCmd.Parameters.Add(New SqlParameter("@startDate", SqlDbType.DateTime)) lSqlCmd.Parameters("@startDate").Value = lTTState.startDate lSqlCmd.Parameters.Add(New SqlParameter("@endDate", SqlDbType.DateTime)) lSqlCmd.Parameters("@endDate").Value = lTTState.endDate
1
2052
by: Paperback Writer | last post by:
I need to insert null in a DateTime field and in the ASP.Net i got this error: SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM. How to accomplish that ? -- Please, check my theSpoke: http://www.thespoke.net/MyBlog/dgroh/MyBlog.aspx
5
35229
by: mlafarlett | last post by:
Alright..I've found lots of info on this error and most say assign System.DBNull.Value, System.Convert.DBNull, or System.Data.SqlTypes.SqlDateTime.Null to my stored proc param and the problem will be solved...NOT. I suspect all of these are the same thing, however, none solve my problem. What I have is vb.net code trying to put a null in a sql2000 datatime field. To further confuse things, it works on my PC and not from another. I...
3
5487
by: aling | last post by:
Execute following T-SQL within Queary Analyzer of SQL Server 2000: ======================================= DECLARE @dTest DATETIME SET @dTest='2001-1-1 1:1:1:991' SELECT @dTest SET @dTest='2001-1-1 1:1:1:997' SELECT @dTest
1
3945
by: lairpr | last post by:
I am having this kind of error when trying to insert a null value; SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM. bellow is my code, thanks protected void btnAddTime_Click(object sender, EventArgs e) { try {
0
1110
by: Randy Smith | last post by:
Hi ALL, I've got some date fields that will end up being null, but I can set it to some other date. However, I tried setting the fields to "01/01/1900", and I get the same error on that as well. Can someone tell me what I'm doing wrong? I've tried a bunch of different combinations, but nothing I do seems to make any difference. I even tried casting it to a DateTime, but got a compile error (cannot convert type "string" to...
4
5594
by: Manikandan | last post by:
Hi, I'm inserting a datetime values into sql server 2000 from c# SQL server table details Table name:date_test columnname datatype No int date_t DateTime C# coding
0
8896
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9653
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. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9451
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8328
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 launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6869
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4771
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 the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4942
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3395
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2872
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.