Focal Point
SQL Server datetime field format

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/1381057331/m/7121008802

January 22, 2007, 04:08 AM
DarrenH
SQL Server datetime field format
Hi,
I am trying to insert a timestamp into a datetime field on SQL Server using a stored procedure in DataMigrator. Does anybody have an example of how you format a datetime value to pass through? I have attempted this by trying to concatenate &DATE and &TOD, but I keep getting an error saying that this is in the incorrect format.

Thanks!


Prod: Service Manager 5.5 - DataMigrator 7.6 - Win2K
Test: Service Manager 5.5 - DataMigrator 7.6 - Win2K
Local: DevStudio 5.5.3 - Management Console
- Windows XP SP2
January 23, 2007, 09:27 AM
Jessica Bottone
This works for me in Oracle:

-SET &TOD_H = EDIT(&TOD,'99');
-SET &TOD_M = EDIT(&TOD,'$$$99');
-SET &TOD_S = EDIT(&TOD,'$$$$$$99');
-SET &TOD_HMS = &TOD_H | &TOD_M | &TOD_S;
-SET &TS = &YYMD | &TOD_HMS;
-TYPE TS: &TS

SQL SQLORA
INSERT INTO OWNER.TABLENAME
(DATE_FIELD)
VALUES (TO_TIMESTAMP('&TS.EVAL','YYYYMMDDHH24MISS'))
;
END
-RUN


Data Migrator 5.3, 7.1, 7.6
WebFOCUS 7.1, 7.6, 7.7
SQL Server, Oracle, DB2
Windows
January 23, 2007, 09:34 AM
DarrenH
Ah - didn't think about splitting it up into individual elements - but good idea Smiler
I'll let you know if I find a one-liner to do this too.

Thanks!


Prod: Service Manager 5.5 - DataMigrator 7.6 - Win2K
Test: Service Manager 5.5 - DataMigrator 7.6 - Win2K
Local: DevStudio 5.5.3 - Management Console
- Windows XP SP2
February 04, 2007, 06:22 AM
FrankDutch
Darren

I was reading this "old" issue and I wondered if this works already, otherwise you might be able to let this done by the SQL proces itself.
I think you can define a default value on the database that automatically insert the datetime to the actual value unless you enter an other value.

good luck




Frank

prod: WF 7.6.10 platform Windows,
databases: msSQL2000, msSQL2005, RMS, Oracle, Sybase,IE7
test: WF 7.6.10 on the same platform and databases,IE7

March 08, 2007, 08:29 AM
DarrenH
If anybody needs this - I've managed to figure it out.
Darren 1 : iWay 0
Smiler

-*Create the timestamp variable in the correct format for SQL Server to use
-SET &TIME = EDIT(&TOD,'99:$99:$99')||'.000';
-TYPE &TIME

-SET &DAY = EDIT(&YYMD,'9999-99-999');
-SET &TS = &DAY||&TIME;


Prod: Service Manager 5.5 - DataMigrator 7.6 - Win2K
Test: Service Manager 5.5 - DataMigrator 7.6 - Win2K
Local: DevStudio 5.5.3 - Management Console
- Windows XP SP2
March 08, 2007, 09:08 AM
DarrenH
Darren 1: 0 iWay
Smiler

-*Create the timestamp variable in the correct format for
-*SQL Server to use
-SET &TIME = EDIT(&TOD,'99:$99:$99')||'.000';
-TYPE &TIME

-SET &DAY = EDIT(&YYMD,'9999-99-999');
-SET &TS = &DAY||&TIME;


Prod: Service Manager 5.5 - DataMigrator 7.6 - Win2K
Test: Service Manager 5.5 - DataMigrator 7.6 - Win2K
Local: DevStudio 5.5.3 - Management Console
- Windows XP SP2