insert a value into a datetime column

Last Post 31 Mar 2008 07:28 AM by AndiArt. 5 Replies.
AddThis - Bookmarking and Sharing Button
Author Messages
AndiArt
New Member
New Member

--
31 Mar 2008 05:47 AM
Hello,

I want to insert via java and sql a date into a datetime column of my database. the date I hava as a string literal like "01.04.2008" means dd.mm.yyyy. If I try to insert it the sql-server complains in the following way: (similar)
while converting a char into a datetime the datetime is out of valid range.
How can I get my String into the database?

Regards,
Andi
AndiArt
New Member
New Member

--
31 Mar 2008 07:00 AM
Neither the string without seperators nor the one with the convert function work on my system. always the error message I quoted above.
AndiArt
New Member
New Member

--
31 Mar 2008 07:28 AM
i do :
insert into t_teilnehmer_ausfälle (Tln_Dienstnummer, No_von) VALUES ('1','20080104')

and it's out of range...
AndiArt
New Member
New Member

--
01 Apr 2008 12:16 AM
i run the query in the query editor. there are triggers, but I think they make restrictions only on the first column (Tln_Dienstnummer), which I payed respect to in my query then. The column is defined as a datetime. I also tried the following query:
insert into t_teilnehmer_ausfälle (tln_dienstnummer, No_Von) VALUES ('F11477', convert(datetime, '20081224', 112))
it results also in an out of range error.

sorry, I don't know how to get the ddl...
AndiArt
New Member
New Member

--
01 Apr 2008 12:24 AM
i think this is the ddl:

USE [FHPol_Lehrgang_XP_2]
GO
/****** Objekt: Table [dbo].[T_Teilnehmer_Ausfälle] Skriptdatum: 04/01/2008 09:22:36 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[T_Teilnehmer_Ausfälle](
[Tln_Dienstnummer] [nvarchar](6) NOT NULL,
[No_ID] [smallint] NOT NULL CONSTRAINT [DF__Temporary__No_ID__05F8DC4F] DEFAULT (0),
[No_Von] [datetime] NULL,
[No_Bis] [datetime] NULL,
[No_Beginn] [datetime] NULL CONSTRAINT [DF__Temporary__No_Be__06ED0088] DEFAULT ('12/30/1899'),
[No_Ende] [datetime] NULL CONSTRAINT [DF__Temporary__No_En__07E124C1] DEFAULT ('12/30/1899 23:59:59'),
[No_Grund] [nvarchar](50) NULL,
[No_LG_ID] [nvarchar](50) NULL,
[No_Bemerkung] [varchar](8000) NULL,
[No_Urlaubstage] [decimal](18, 1) NULL,
[msrepl_tran_version] [uniqueidentifier] NOT NULL DEFAULT (newid()),
[No_Sachb_Datum] [datetime] NULL,
[No_Sachb] [nvarchar](50) NULL,
CONSTRAINT [aaaaaT_Teilnehmer_Ausfälle_PK] PRIMARY KEY NONCLUSTERED
(
[Tln_Dienstnummer] ASC,
[No_ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON, FILLFACTOR = 90) ON [PRIMARY]
) ON [PRIMARY]

GO
SET ANSI_PADDING OFF
GO
ALTER TABLE [dbo].[T_Teilnehmer_Ausfälle] WITH NOCHECK ADD CONSTRAINT [T_Teilnehmer_Ausfälle_FK00] FOREIGN KEY([Tln_Dienstnummer])
REFERENCES [dbo].[T_Teilnehmer] ([Tln_Dienstnummer])
GO
ALTER TABLE [dbo].[T_Teilnehmer_Ausfälle] NOCHECK CONSTRAINT [T_Teilnehmer_Ausfälle_FK00]
AndiArt
New Member
New Member

--
01 Apr 2008 01:26 AM
I have the solution. The table needs an insert on all 4 datetime-columns, which are in the table and not only on one of them.

thank you for helping.


Acceptable Use Policy
---