DateDiff
Hi,
I have a report which shows the sign in and sign out time of the user, what I now want is to show the amount of hours between those times. The report is a simple structure containing a header with the username, a masterData band which displays the signin/out times and a blank footer. Problem is the masterData band grabs each row from the database table and prints it, and only knows if its a signout or in by a coloum called type in the row. but I need to try and add something in the footer or somewhere which will compare those two times printing out the hour differance (similar to a SUM command but the opposite lol). I am quite a noob at c++ and prefeer c# but have to use c++ to do this for the old system. The only varibles which are passed to the report are the from and to date , nothing to do with the times are sent so can not relate to those varibles.
Question is firstly; How do you referance each of the diffrant times printed? Would I have to write a new sql query? Or something like; if( <BDEQuery2.type> == 1) myVal= SigninTime; else if(<BDEQuery2.type == 2) myVal2 = SignoutTime? then run a compare?
Next Question would be how do you compare two dates to print the hours? Cant seem to find the DateDiff Function in the list? not that I know how to use it anyway..
Ill list what code I have although do not think it relates to what I want but at least you can show me where and what I need to put ;-)
Thanks in advance!
I have a report which shows the sign in and sign out time of the user, what I now want is to show the amount of hours between those times. The report is a simple structure containing a header with the username, a masterData band which displays the signin/out times and a blank footer. Problem is the masterData band grabs each row from the database table and prints it, and only knows if its a signout or in by a coloum called type in the row. but I need to try and add something in the footer or somewhere which will compare those two times printing out the hour differance (similar to a SUM command but the opposite lol). I am quite a noob at c++ and prefeer c# but have to use c++ to do this for the old system. The only varibles which are passed to the report are the from and to date , nothing to do with the times are sent so can not relate to those varibles.
Question is firstly; How do you referance each of the diffrant times printed? Would I have to write a new sql query? Or something like; if( <BDEQuery2.type> == 1) myVal= SigninTime; else if(<BDEQuery2.type == 2) myVal2 = SignoutTime? then run a compare?
Next Question would be how do you compare two dates to print the hours? Cant seem to find the DateDiff Function in the list? not that I know how to use it anyway..
Ill list what code I have although do not think it relates to what I want but at least you can show me where and what I need to put ;-)
TDateTime ShopTimeFrom;
TDateTime ShopTimeTo;
void MasterData1OnBeforePrint(TfrxComponent Sender)
{
MasterData1.Visible = true;
if( (ShopTimeFrom > 0) && (ShopTimeTo > 0) )
{
TDateTime ClockInOutTime;
ClockInOutTime = StrToDateTime(DateToStr(<BDEQuery2."LOG_DATE">)+" "+<BDEQuery2."LOG_TIME">);
if( (ClockInOutTime >= ShopTimeFrom) && (ClockInOutTime <= ShopTimeTo) )
{
}
else
{
MasterData1.Visible = false;
}
}
else
{
}
}
{
if( (<BDEQuery1."SHOPTIMEFROM"> > "") && (<BDEQuery1."SHOPTIMETO"> > "") )
{
ShopTimeFrom = StrToDateTime(<DateF> + " " + <BDEQuery1."SHOPTIMEFROM">);
ShopTimeTo = StrToDateTime(<DateT> + " " + <BDEQuery1."SHOPTIMETO">);
}
else
{
ShopTimeFrom = 0;
ShopTimeTo = 0;
}
}
Thanks in advance!
Comments
2. Do ShopTimeTo - ShopTimeFrom