DateDiff

edited July 2014 in FastReport 4.0
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 ;-)
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

  • gpigpi
    edited 1:38PM
    1 Use IIF function
    2. Do ShopTimeTo - ShopTimeFrom

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.