Showing posts with label datetime. Show all posts
Showing posts with label datetime. Show all posts

Monday, February 20, 2012

Problem inserting time stamp 24:00:00.000 into a datetime column

Hi,
Problem inserting time stamp 24:00:00.000 to an SQL 2K database. App
code(EJB-SQL JDBC) constantly receives reading and it calls add procedure to
insert reading datetime. So, if reading comes exactly at midnight, the inser
t
fails.
Any help is really appreciated.
thanksHi
Midnight is 00:00:00.000!
John
"Ajay" <Ajay@.discussions.microsoft.com> wrote in message
news:E8F82952-F6C0-45D7-AED2-245D745A6273@.microsoft.com...
> Hi,
> Problem inserting time stamp 24:00:00.000 to an SQL 2K database. App
> code(EJB-SQL JDBC) constantly receives reading and it calls add procedure
> to
> insert reading datetime. So, if reading comes exactly at midnight, the
> insert
> fails.
> Any help is really appreciated.
> thanks
>

Problem inserting Now() into a datetime field

Hi

I am trying to insert value retrieved from Now() into a datetime field in my MSDE database, but I am getting the following error, and I have no idea what is going wrong.

Arithmetic overflow error converting expression to data type datetime.
The statement has been terminated.

Here is the code I am using:

Dim user As String = MyContext.User.Identity.Name.ToString
Dim TimeDate As DateTime = Now()
Dim status As String = "Pending"

With SqlOrders.InsertParameters
.Item("UserName").DefaultValue = user
.Item("OrderDate").DefaultValue = TimeDate
.Item("Status").DefaultValue = status
End With
SqlOrders.Insert()

The date is being returned in this format23/03/2006 02:01:52, which is the same format as it should appear in the database.

could anyone please tell me where I am going wrong?
Datetimes don't have a format. Varchar/strings that represent a datetime have a format. Make sure your OrderDate parameter is set to a datetime datatype, and your problem should go away, probably.|||Thankyou, I added .Item("OrderDate").Type = TypeCode.DateTime and it works fine now :)

problem inserting datetime

Since two days, I suddenly experience trouble inserting datetime values on my contracters sql server
As example I can created a table like this:
CREATE testDateTime
(dateTime DATETIME)
and insert:
insert testDateTime (dateTime)
values ('13-8-2005 11:56:39')
this works OK on my local Microsoft SQL Server 2000, but since two days not anymore on my contracters Microsoft SQL Server ("The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value")
Maybe they had an upgrade with changes in the way datetime values are handled? I sent an email to the administators of my contractors webserver, and I will put a question on a Microsoft SQL Server forum. I have the same problem with inserting smalldatetime valuesThe interpretation of the datetime value depends on the language and date format setting. For example, if you SET LANGUAGE to us_english then this will not work. You need to use the ISO format to make sure that the datetime value is interpreted correctly irrespective of language or date format setting. So do instead: '20050813T11:56:39'.|||Feel like reading some more? :)
http://www.karaszi.com/SQLServer/info_datetime.asp
http://www.sql-server-performance.com/fk_datetime.asp
--
Frank Kalis
Microsoft SQL Server MVP
http://www.insidesql.de
Ich unterstütze PASS Deutschland e.V. (http://www.sqlpass.de)