Hello everyone,
we want to save a data table to a database and later query the database (using MS SQL) to retrieve the table. Since we run into some problems transferring the timestamp to the database, we set up a workaround. First of all, the table in JMP has a "date" column named "SecondsSince1904", where the datetime is stored as elapsed seconds since the 1904 epoche (01.01.1904 00:00:00). This column is formated as "Fixed Dec (30,0)". To transfer the data table to the database, we use the following script:
Names Default To Here(1);
dt = Current Data Table();
// This will delete the table "yourTable" in the database. BE CAREFUL!!!
Open Database(
"yourDSNconnectionString",
"DROP TABLE dbo.yourTable"
);
// This will upload the table "dt = Current Data Table" to the database, where it will be saved as "yourTable".
dt << Save Database("yourDSNconnectionString",
"dbo.yourTable"
);
// After saving the table to the database, we find the column "SecondsSince1904" formatted as FLOAT.
// Now we want to manipulate the table "yourTable" and add a computed column named "timestamp", where we will display the correct timestamp,
// i. e. something like "2015-09-26 00:00:02.000".
// We do this by calculating the correct timestamp from the column "SecondsSince1904". We also add an additional column named "SecondsAfterMidnight" just for fun.
dbc = Create Database Connection(
"yourDSNconnectionString"
);
Execute SQL(dbc,
"
ALTER TABLE dbo.yourTable ADD timestamp AS
DATEADD(ss, (CAST(yourTable.SecondsSince1904 AS BIGINT)%86400),
DATEADD(dd, (CAST(yourTable.SecondsSince1904 AS BIGINT)/86400), '1904-01-01' ) );
ALTER TABLE dbo.yourTable ADD SecondsAfterMidnight AS
(CAST(yourTable.SecondsSince1904 AS BIGINT)%86400)
"
);
Close Database Connection(dbc);
So far so good. No problem up to this point. The "SecondsAfter1904" are correctly transferred to the database and the timestamp is also calculated correctly. Have a look in the database:

Now we query the database and retrieve the table back into JMP by going to File > Database > Open Table. And this is the point where things get messed up. Have a look in JMP:

The timestamp is corrupt. Some error happend. Maybe a bitshift or something like that. To draw conclusions, i incremented the SecondsSince1904 "bitwise".
Does anyone know what happened here? Is this a bug? Any help is appreciated.
Cheers,
Victor