Hi,
I have (2) CMD statements that are used to log when a table starts loading in the database with our automated BCP process and another that will log when it completes and determine the duration between.
But...I'm having problems using datediff() to convert the duration calculated in seconds to minutes.
Here's the code snippet used to create the 1st log record:
update TABLE_LOAD_TRAC KING
set last_load_start =getdate(),
last_load_end = null,
load_duration = null,
num_rec= 0,
last_updated_by ='LOADING'
where table_nm= 'TABLE_A'
This creates a log record like:
table_nm: TABLE_A
last_load_start : 9:59:40 AM
last_load_end: null
load_duration: null
num_rec: 0
last_updated_by : LOADING
Then...when the load is complete another CMD file updates that record to log the endtime and duration.
Here's the code snippet:
update TABLE_LOAD_TRAC KING
set last_load_end=g etdate(),
load_duration = datediff(ss, last_load_start , getdate()) / 60 ,
num_rec=(select count(*) from TABLE_A),
last_updated_by ='COMPLETE'
where table_nm= 'TABLE_A'
...which results in the record now saying:
table_nm: TABLE_A
last_load_start : 9:59:40 AM
last_load_end: 10:01:14 AM
load_duration: 1.0
num_rec: 267916
last_updated_by : COMPLETE
Problem: load_duration should show something like 1.57
My timestamp examples may be a little off, but it's boiling down to the datediff() only setting the # of full minutes that have passed, not the actual x.y number of minutes that have passed.
I've tried playing around with the format of the load_duration field, but with no luck so far. My current setting for that field is: decimal, precision 18, scale 2
Any suggestions or insight are appreciated!!
Thanks!
--Andrea S.
SQL Server 2000
I have (2) CMD statements that are used to log when a table starts loading in the database with our automated BCP process and another that will log when it completes and determine the duration between.
But...I'm having problems using datediff() to convert the duration calculated in seconds to minutes.
Here's the code snippet used to create the 1st log record:
update TABLE_LOAD_TRAC KING
set last_load_start =getdate(),
last_load_end = null,
load_duration = null,
num_rec= 0,
last_updated_by ='LOADING'
where table_nm= 'TABLE_A'
This creates a log record like:
table_nm: TABLE_A
last_load_start : 9:59:40 AM
last_load_end: null
load_duration: null
num_rec: 0
last_updated_by : LOADING
Then...when the load is complete another CMD file updates that record to log the endtime and duration.
Here's the code snippet:
update TABLE_LOAD_TRAC KING
set last_load_end=g etdate(),
load_duration = datediff(ss, last_load_start , getdate()) / 60 ,
num_rec=(select count(*) from TABLE_A),
last_updated_by ='COMPLETE'
where table_nm= 'TABLE_A'
...which results in the record now saying:
table_nm: TABLE_A
last_load_start : 9:59:40 AM
last_load_end: 10:01:14 AM
load_duration: 1.0
num_rec: 267916
last_updated_by : COMPLETE
Problem: load_duration should show something like 1.57
My timestamp examples may be a little off, but it's boiling down to the datediff() only setting the # of full minutes that have passed, not the actual x.y number of minutes that have passed.
I've tried playing around with the format of the load_duration field, but with no luck so far. My current setting for that field is: decimal, precision 18, scale 2
Any suggestions or insight are appreciated!!
Thanks!
--Andrea S.
SQL Server 2000
Comment