Tech Question : Date Math - TechRepublic
Question
May 22, 2008 at 11:22 AM
dprice_2000

Tech Question : Date Math

by dprice_2000 . Updated 18 years, 2 months ago

I get the following result in a third party tool (correct):
Rqst No. Duration
1 82414 7.0001504629629629629629629629629629629
2 82415 14.000254629629629629629629629629629629

? and this using Visual Studio (wrong)
Rqst No. Duration
1 82414 -90
2 82415 0

?using
SELECT a.rqst_num, ROUND(b.rec_create_tms – a.rec_create_tms) as duration
FROM log a, log b
WHERE a.rqst_num = b.rqst_num
AND a.log_ty_num = 6
AND b.log_ty_num = 9
AND a.rqst_num IN (82415,82414)

Code Snippet:
try
{
string sqlStatement = string.Format(
@”SELECT a.rqst_num,
(b.rec_create_tms – a.rec_create_tms) as duration
FROM log a, log b
WHERE a.rqst_num = b.rqst_num
AND a.log_ty_num = {0}
AND b.log_ty_num = {1}
AND a.rqst_num IN ({2})”, logTy1, logTy2, rqstStr);
IDataReader dataReader2 = DAOHelper.ExecuteSQLStatement(sqlStatement);
while (dataReader2.Read())
{
int rqstNum = dataReader2.GetInt32(0);
int duration = dataReader2.GetInt32(1);

Rqst rqst = new Rqst(rqstNum);
rqst = rqst.GetRqst();
rqst.GenericValue = duration;

rqstList.Add(rqst);
}
dataReader2 = null;
}
catch (Exception exception)
{
throw new Exception(“Common.DAO: ReportDAO: GetAuditReportDetails()”, exception.InnerException);
}

Any ideas?

This discussion is locked

All Comments