I’m really frustated right now, because I just can’t manage to get a VB.NET manually created DATE datatype into a DB2 column which is has the TIMESTAMP datatype.
I tried a few different ways to handle this, but no matter what I do I always get the error “SQL0180N: The syntax of the string representation of a datetime value is incorrect”.
The part in my application which handles the conversion from String to DATE is right here:
Dim neuesDatum As Date
neuesDatum = CDate(jahr & "-" & "0" & monat & "-01 00:00:00")
The String for the conversion looks like this: 2013-01-01 00:00:00
I also tried the german format of a date (01.01.203), tried to use the String without the last part (00:00:00), but no matter what I do it always ends up the same way.
I use a Stored Procedure to insert the Data into a Table. The Date is delivered as the parameter “SollMonat”.
CREATE OR REPLACE PROCEDURE "ADDON21C"."STP_BEITRAGSSATZ_ADD"
(
IN @Id BIGINT,
IN @Typ VARCHAR(100),
**IN @SollMonat TIMESTAMP,**
IN @G VARCHAR(100),
IN @F VARCHAR(100),
IN @H VARCHAR(100),
IN @U1 VARCHAR(100),
IN @U2 VARCHAR(100),
IN @U1erhoeht VARCHAR(100),
IN @U1ermaessigt VARCHAR(100),
IN @RV VARCHAR(100),
IN @ALV VARCHAR(100),
IN @P VARCHAR(100),
IN @RVgf VARCHAR(100),
IN @KVgf VARCHAR(100),
IN @ZusatzKV VARCHAR(100),
IN @ZusatzPV VARCHAR(100),
IN @Inso VARCHAR(100),
OUT @result BIGINT
)
LANGUAGE SQL
SPECIFIC SQL12080109131643
BEGIN
IF @Id IS NULL OR @Id = 0
THEN
INSERT INTO "ADDON21C".BS
(Typ, Sollmonat, G, F, H, U1, U2, U1erhoeht, U1ermaessigt)
VALUES
(@Typ, @SollMonat, @G, @F, @H, @U1, @U2, @U1erhoeht, @U1ermaessigt);
SET @result = IDENTITY_VAL_LOCAL();
END IF;
END
The datatype for “Sollmonat” inside of the datatable is TIMESTAMP, too.
Guys, I would be very happy if you can help me out here. I’m completely out of ideas and no, I can’t save the date as a VARCHAR in the table. Saving is as DATE in the database might be possible, but I believe I’d have the same problem there.
Thanks in advance!
@Steve It would only make the whole thing more confusing, because I build myself a few classes that allow me to map classes into datatables, but be assured that this isn’t what screws this up. When I use a not manually created date, like Date.Now for example, it works fine.
There are a couple of ways you might try this. One is specifically saying that your parameter is a timestamp, and pass in the
Datetype:Another possibility is defining the correct string representation of a date, and then using
.ToString(). Below are a couple format strings, use the one that match your database’s data type.These options have worked for me in the past. The timestamp format string should work all the time (it is the ODBC standard for a timestamp), but the date format string may vary by location, have a look at this article in Information Center.