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

problem with date types

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 2:56:11.987'). This works fine...if you
check the value in the table with query analyzer, it shows in there
properly.

Now, in my app, I'm executing the same query (that I used in QA) and storing
tha in a dataview. If I break and watch the program, the value that's
stored in the dataview is #8/5/2005 2:56:11 PM# with a datatype of
date....so it's truncating my fractions of a second!!!

How can I get my missing time? Thanks.
Nov 21 '05 #1
11 1373
"Rob T" <RT*********@DONTwalchemSPAM.com> schrieb:
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 2:56:11.987'). This works
fine...if you check the value in the table with query analyzer, it shows
in there properly.

Now, in my app, I'm executing the same query (that I used in QA) and
storing tha in a dataview. If I break and watch the program, the value
that's stored in the dataview is #8/5/2005 2:56:11 PM# with a datatype of
date....so it's truncating my fractions of a second!!!


Make sure you read the "Remarks" section of the "'DateTime' structure"
chapter of the documentation.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #2
I assume you're referring to the fact that the datetime only goes to the
nearest second...or am I missing something? I was hoping that when the
datastructure of the dv was created that I could store it as a string....?

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
"Rob T" <RT*********@DONTwalchemSPAM.com> schrieb:
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 2:56:11.987'). This works
fine...if you check the value in the table with query analyzer, it shows
in there properly.

Now, in my app, I'm executing the same query (that I used in QA) and
storing tha in a dataview. If I break and watch the program, the value
that's stored in the dataview is #8/5/2005 2:56:11 PM# with a datatype of
date....so it's truncating my fractions of a second!!!


Make sure you read the "Remarks" section of the "'DateTime' structure"
chapter of the documentation.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3
Rob,

Are you sure of that, what you see is the US representation (which make
people outside that sometimes crazy) in the IDE.

The dateTime itself is a format in long, containing ticks starting at the
year that the Georgian Calendar started to be used in England (and therefore
in its colonies from which the US was one at that time).

I hope this helps,

Cor
Nov 21 '05 #4
(head spinning) I just wanted to know how I can get a date field with
fractions of a second into my dataview..........

-Regards from New England!

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
Rob,

Are you sure of that, what you see is the US representation (which make
people outside that sometimes crazy) in the IDE.

The dateTime itself is a format in long, containing ticks starting at the
year that the Georgian Calendar started to be used in England (and
therefore in its colonies from which the US was one at that time).

I hope this helps,

Cor

Nov 21 '05 #5
"Rob T" <RT*********@DONTwalchemSPAM.com> schrieb
(head spinning) I just wanted to know how I can get a date field
with fractions of a second into my dataview..........

In your dataview, you don't have any information stored. Probably a
datatable stores it. This also includes the fractions of a second. Your
problem is probably converting the value into a string including the
fractions.

We don't know how you convert the value or have it converted to a string,
thus it's hard to give a suggestion. If you use the Date's ToString method,
have a look at the ToString function's documentation how to include the
fractions. There's also a link to this chapter:

http://msdn.microsoft.com/library/en...matstrings.asp
Armin

Nov 21 '05 #6
Rob,
In addition to the other comments:

| date....so it's truncating my fractions of a second!!!
Are you certain that it is truncating them as opposed to simply not showing
them?

See the remarks at:

http://msdn.microsoft.com/library/de...classtopic.asp

<quote>
DateTime values are measured in 100-nanosecond units called ticks, and a
particular date is the number of ticks since 12:00 midnight, January 1, 1,
A.D. (C.E.)
</quote>

100-nanosecond units should be more then enough to cover 1000th of a second!
Remember that a nanosecond is one billionth (10 to -9th) of a second.

DateTime values by default are only displayed to seconds, however this is
normally only a Display Issue! If you want the to see the 100-nanosecond
units, you need to use a custom DateTime format.

http://msdn.microsoft.com/library/de...matstrings.asp

For example:

Dim aDate As DateTime = DirectCast(theDataView!theDateColumn,
DateTime)

Debug.WriteLine(aDate.ToString(), "default formatting")
Debug.WriteLine(aDate.ToString("yyyy.MM.dd hh:mm:ss.fffffff"),
"custom formatting")

The ".fffffff" says to display seconds fractions to the full seven digits
(100-nanoseconds), try the above two lines with the Date column in your
DataView. Try the above two lines with DateTime.Now

Dim aDate As DateTime = DateTime.Now

Debug.WriteLine(aDate.ToString(), "default formatting")
Debug.WriteLine(aDate.ToString("yyyy.MM.dd hh:mm:ss.fffffff"),
"custom formatting")

I suspect your fractions of seconds are not being truncated, rather they are
simply not being displayed!

Depending on how you are displaying the date you need to include a "format"
that includes fractions of seconds. For example with the Windows Forms
DataGrid, you can add a TableStyle for your table, then add a
DataGridTextBoxColumn for your date column. You can then set
DataGridTextBoxColumn.Format to a custom format that includes the fractions
of seconds you want displayed...
Hope this helps
Jay

"Rob T" <RT*********@DONTwalchemSPAM.com> wrote in message
news:uV**************@TK2MSFTNGP14.phx.gbl...
| 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 2:56:11.987'). This works fine...if
you
| check the value in the table with query analyzer, it shows in there
| properly.
|
| Now, in my app, I'm executing the same query (that I used in QA) and
storing
| tha in a dataview. If I break and watch the program, the value that's
| stored in the dataview is #8/5/2005 2:56:11 PM# with a datatype of
| date....so it's truncating my fractions of a second!!!
|
| How can I get my missing time? Thanks.
|
|
Nov 21 '05 #7
Rob,

Before this is misunderstood.

http://msdn.microsoft.com/library/de...classtopic.asp

<quote>
DateTime values are measured in 100-nanosecond units called ticks, and a
particular date is the number of ticks since 12:00 midnight, January 1, 1,
A.D. (C.E.)
</quote>


Be aware that this is for system.datetime. SQL server datetime is as I tried
to describe it.
I always forget that date therefore :-)

http://msdn.microsoft.com/library/de...a-db_9xut.aspI hope this helps,Cor

Nov 21 '05 #8
Cor,
My point is that System.DateTime has create precision (uses smaller units)
then the DateTime on SQL Server.

Rob already mention that his SQL data had "1000th of a second" precision.

Hope this helps
Jay

"Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
| Rob,
|
| Before this is misunderstood.
| >
| >
http://msdn.microsoft.com/library/de...classtopic.asp
| >
| > <quote>
| > DateTime values are measured in 100-nanosecond units called ticks, and a
| > particular date is the number of ticks since 12:00 midnight, January 1,
1,
| > A.D. (C.E.)
| > </quote>
|
| Be aware that this is for system.datetime. SQL server datetime is as I
tried
| to describe it.
| I always forget that date therefore :-)
|
|
http://msdn.microsoft.com/library/de...a-db_9xut.aspI
hope this helps,Cor
|
Nov 21 '05 #9
"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> schreef in bericht
news:O9**************@TK2MSFTNGP12.phx.gbl...
Cor,
My point is that System.DateTime has create precision (uses smaller units)
then the DateTime on SQL Server.

Rob already mention that his SQL data had "1000th of a second" precision.


I saw that you showed it, I did not do any addition or comment to that.

However that the starting date of datetime is not always the same can be
confusing if you have first to handle with datetimes and therefore my
comment. It could have been seen by others than you or me that you made a
correction to my message about the start of the date in a SQL server.

Cor
Nov 21 '05 #10
Doh!
| My point is that System.DateTime has create precision (uses smaller units)
| then the DateTime on SQL Server.
That's has *greater* precision.

Jay

"Jay B. Harlow [MVP - Outlook]" <Ja************@msn.com> wrote in message
news:O9**************@TK2MSFTNGP12.phx.gbl...
| Cor,
| My point is that System.DateTime has create precision (uses smaller units)
| then the DateTime on SQL Server.
|
| Rob already mention that his SQL data had "1000th of a second" precision.
|
| Hope this helps
| Jay
|
| "Cor Ligthert [MVP]" <no************@planet.nl> wrote in message
| news:%2****************@tk2msftngp13.phx.gbl...
|| Rob,
||
|| Before this is misunderstood.
|| >
|| >
|
http://msdn.microsoft.com/library/de...classtopic.asp
|| >
|| > <quote>
|| > DateTime values are measured in 100-nanosecond units called ticks, and
a
|| > particular date is the number of ticks since 12:00 midnight, January 1,
| 1,
|| > A.D. (C.E.)
|| > </quote>
||
|| Be aware that this is for system.datetime. SQL server datetime is as I
| tried
|| to describe it.
|| I always forget that date therefore :-)
||
||
|
http://msdn.microsoft.com/library/de...a-db_9xut.aspI
| hope this helps,Cor
||
|
|
Nov 21 '05 #11
"Rob T" <RT*********@DONTwalchemSPAM.com> schrieb:
I assume you're referring to the fact that the datetime only goes to the
nearest second...or am I missing something?


No, I was referring to this paragraph:

| Time values are measured in 100-nanosecond units called ticks

You can determine the number of ticks by querying the 'Tick' property of
your 'DateTime' object.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #12

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

Similar topics

0
by: RJS | last post by:
Hi all, I can't get a py2exe compiled app to run with numarray (numarray-0.5.win32- py2.2). Also wxPythonWIN32-2.3.3.1-Py22 and ActivePython-2.2.1-222. In the sample below, commenting out...
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 $...
7
by: jslowery | last post by:
Hello, I'm new to both PostgreSQL and psycopg and I'm trying to connect to my database running on localhost. I have postgres setup to do md5 authentication and this works when using a db admin tool...
1
by: Jim | last post by:
For some reason the compiler is telling me that I must declarethe variable @costcenter_tmp on lines 74 and 98...but if i put a select statement in ther (for testing) before the loop I get data back...
1
by: php newbie | last post by:
Hello, I am trying to insert some date values into a table. I am using ODBC prepared statements to (potentially) improve performance. The statement syntax I am using is this: INSERT INTO...
3
by: Dominic Messenger | last post by:
I have several elements that have optional child elements and attributes that are xs:dates. I have been using System.DateTime and the XmlAttribute/XmlElement attributes, but these will never work...
11
by: Geoff Jones | last post by:
Hi I have a table that has a column with Date types. I am trying to view certain rows in the table using a DataView. Using the filter, I can view the rows with, for example, the date equal...
2
by: yqlu | last post by:
I hava developed a client in C# that is connected to a 3-party XML Web Services developed in Java based on the AXIS 1.1. Most methods call are successful except for one method named "findObjects"...
9
by: Ron | last post by:
Hi All, I've recently installed a program written in Access 2000 on a laptop. The laptop had an existing Office 2000 Pro which of course included Access. But the program acts oddly (more oddly...
5
by: pradeep84 | last post by:
Hi .. friends.. in the below program public void actionPerformed(ActionEvent ae) { int flag=0; s1=(from.getText()); s2=(to.getText()); if(ae.getSource()==view) {
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.