How to calculate the time duration on a datetime column?

Hi guys,
I've done some search on this forum and everywhere else but I can't seem to get this right, at the beggining it sounded like something very simple to accomplish, for the instance with Excel but I'm struggling to get it to work with Crystal Reports on Microsoft Visual Studio 2008.
I have a datetime column (SQL Server 2000) that I wanted to calculate the the time duration on the report group footer, unfortunatelly the built-in SUM function cannot be applied and I've tried several formulas that I've found on the internet without any luck. I'm using a datetime column to store only the time because I'm stuck with SQL Server 2000 which doesn't have a time data type.
Would you guys know how to do it by any chance?
Some sample code I've tried: http://www.minisolve.com/TipsAddUpTime.htm
Thanks a lot,
Paul
Edited by: Paul Doe on Dec 12, 2009 5:41 PM
Some sample data:
EMPLOYEE     WORK HOURS
=========     =================
JOHN DOE      1900-01-01 01:00:05
JOHN DOE      1900-01-01 00:20:00
JOHN DOE      1900-01-01 01:30:15
=========     =================
HOURS WORKED: 02:50:20
Edited by: Paul Doe on Dec 12, 2009 5:42 PM
Edited by: Paul Doe on Dec 12, 2009 5:45 PM

Guess what, by further testing the code on the website mentioned above I got it working.
Pus, I needed to change the grouping on the code, so I had to come up with a way to update the formulas based on the groupping field.
Considering "call_date" is the field that you are groupping by on the designer use the following code to update the formula:
CrystalReportObj = new ReportDocument();
CrystalReportObj.Load("C:\\reportfile.rpt");
FieldDefinition FieldDef;
//Get formula
FormulaFieldDefinition FormulaDef1;
FormulaDef1 = CrystalReportObj.DataDefinition.FormulaFields["SubHours"];
//Get formula
FormulaFieldDefinition FormulaDef2;
FormulaDef2 = CrystalReportObj.DataDefinition.FormulaFields["subMinSec"];
//Update the formula to work with the new grouping field,
//this must be called first else will throw an exception
FormulaDef1.Text = FormulaDef1.Text.Replace("call_date", "call_extension");
FormulaDef2.Text = FormulaDef2.Text.Replace("call_date", "call_extension");
//Get the new field we are grouping by
FieldDef = CrystalReportObj.Database.Tables[0].Fields["call_extension"];
//Replace current grouping field with the new one,
//considering there only one group in the report, index 0
CrystalReportObj.DataDefinition.Groups[0].ConditionField = FieldDef;
Have fun.
Edited by: Paul Doe on Dec 12, 2009 8:43 PM
Edited by: Paul Doe on Dec 12, 2009 8:53 PM

Similar Messages

  • How to calculate the time between start trigger,first scan and first A/D in DAQ

    Environment: Labview 6.1, N6052E DAQ board(max scan rate=333KHz, max channel rate=333KHz, settling time=3.5usec+1LSB)
    I am using external scan clock 10K scan/s collecting data on 16 AI channels, and external channel clock 200KHz.
    Could show me how to calculate the time betweent he start trigger, the first scan and the first A/D conversion?
    Thanks

    I read the one you give to me. still cannot work out. I am using Labview 6.1 DAQ vi, including AI config.vi. clock config.vi, AI control.vi, AI read.vi, working on colect data on 16 AI channels. So I belong to SCAN function and external scan and sampling timing, right?
    But it says the T1 and T2 are determined by external signals. How can I calculate that?
    T1=1/10KHz or T1=1/160Khz?
    T2=1/200KHz?
    Is the above correct?

  • How to Calculate the Time Between two days in ABAP

    Hi,
                  I have one scenario like i need to calculate the time between two days please can you suggest me.
    Thanks,
    Harinath

    Hi Peeleti,
                Check this code,
    DATA : DATE1 LIKE SY-DATUM VALUE '19830125',
           DATE2 LIKE SY-DATUM VALUE '20070219',
           DAYS1 TYPE I,
           WEEK1 TYPE I,
           MONTH1 TYPE I,
           YEAR1 TYPE I,
           C_YEARS1 TYPE I.
    CALL FUNCTION 'HR_99S_INTERVAL_BETWEEN_DATES'
    EXPORTING
      BEGDA           = DATE1
       endda           = DATE2
      TAB_MODE        = ' '
    IMPORTING
      DAYS            = DAYS1
      C_WEEKS         =
      C_MONTHS        = C_YEARS1
      C_YEARS         = C_YEARS1
      WEEKS           = WEEK1
      MONTHS          = MONTH1
      YEARS           = YEAR1.
      D_MONTHS        =
      MONTH_TAB       =
    *WRITE : / 'DAYS   = ', DAYS1,
            / 'WEEKS = ',WEEK1,
          /  'MONTHS = ', MONTH1,
          / 'YEARS   = ', YEAR1.
    Using this code you can calculate the No Of Days Between two dates. Based On days you will easily calculate the Hour. [  No of days * 24 ].
    Thanks.
    Reward If helpful.

  • How to calculate the time difference in answers

    Hi,
    I need to calculate the time difference in BI answers and I dont have the access to the repository. I have the data in the following format
    10/12/2005 7:24:19 PM 10/12/2005 7:32:04 PM
    10/12/2005 7:50:47 PM 10/12/2005 8:52:36 PM
    10/12/2005 7:54:23 PM 11/4/2005 10:47:32 PM
    10/12/2005 9:05:51 PM 10/12/2005 9:08:58 PM
    10/12/2005 9:07:42 PM 10/12/2005 9:14:47 PM
    10/12/2005 9:09:02 PM 10/12/2005 9:10:57 PM
    I need to get the elapased hours between these two columns. Please help me
    Thanks

    you can use beans or create a case when statement like:
    case
    when TimeStampDiff(SQL_TSI_Min, table.column1, table.column2 ) <= 60 then 1 else
    when TimeStampDiff(SQL_TSI_Min, table.column1, table.column2 ) > 60 and TimeStampDiff(SQL_TSI_Min, table.column1, table.column2 ) <= 90 then 1.5 else
    when TimeStampDiff(SQL_TSI_Min, table.column1, table.column2 ) > 90 and TimeStampDiff(SQL_TSI_Min, table.column1, table.column2 ) <= 150 then 2.5 else
    end

  • How to calculate the Time difference between 2 dates

    HI All,
    I am using HR_hk_diff_btw_2_dates to calculate the employee service dates.
    For that i  am inputing his hire date and Term dates and Output format as '05' i am getting output perfectly....
    But problem is  whe i am inputting the employee hire date is Dec 1 2007 and Term date is
    March 31 2009 It is coming as 1 year 3 months  31 days instead of 1 year 4 months directly .......How could we make it make last date also working day and get the O/p as 1 year 4 months ?Please Advice..
    Regard
    sas

    1. FM for difference betwwen two times:SCOV_TIME_DIFF
    Import parameters               Value
    IM_DATE1                        2008-01-01
    IM_DATE2                        2008-01-01
    IM_TIME1                        10:00:00
    IM_TIME2                        11:30:00
    Export parameters               Value
    EX_DAYS                         0
    EX_TIME                         01:30:00
    2. SD_CALC_DURATION_FROM_DATETIME : Finds the difference between two date/time and report the difference in hours
    L_MC_TIME_DIFFERENCE : Finds the time difference between two date/time

  • How to determine the time duration of each job for a particular report

    Hi guys,
    I am facing a very interesting problem which I want to share with all of you-hoping to get some input from you
    enlightened fellas :).
    I have vendor and vendor sub-range maintained in one custom table. For each vendor I have got article site combination maintained in another table. The thing is I have to execute this program in background. Now for each vendor I may have only 1 article or multiple articles. So if I schedule the job for 60 min. say then for 1 article the time alloted will be too big and for multiple articles the time alloted may prove to be too small. Another thing from a functional point of view is a vendor which has 1 article today may have more articles added to his name tomorrow (if the customer likes his product the company may buy more from him). So the point is we have to dynamically adjust the time alloted for each job.
    I could not find any utility in ABAP which can do this.
    Can any of you please help me?
    Thanks a lot !
    Hasso.
    Edited by: Hasso14 on Apr 28, 2011 3:06 PM

    Exaactly-only I want to find the best time needed to finish for an article or multiple articles i.e I do not know how many articles will be available for each vendor beforehand before doing a select on the 2 tables. But once I know the number (maybe 1 or more than 1) I want to allot the best time for that article/lot of articles(maybe JOB_OPEN  technique ?).Also the number of articles may vary over time so the algorithm should take care of that too.-quite a tricky prob :)-I would request the others to see this reply which I think will clarify their doubts.
    Edited by: Hasso14 on Apr 28, 2011 9:03 PM

  • How to calculate the time to render a JTable?

    Hi all,
    I have a table that is taking quite some time to render after I edit one of its cells.
    I'd like to know the complete amount of time it takes to render all the cells.
    Considering the cells are rendered inside the java classes, I have no clue how can I do that.
    Any help would be appreciated.

    878279 wrote:
    Tried VisualVM and it's really a nice tool. The problem is that it shows only the time for each method to run.Exactly, so if you look at the event queue thread and drill down you can see which method is 'taking quite some time' after you did an edit. Note that you typically need to drill down a bit into the Swing painting stack but ultimate it's end up in the methods you wrote.
    See for example: http://imageshack.us/photo/my-images/827/simplecpusampling.png/ when sampling this program:
    import java.awt.EventQueue;
    import javax.swing.JFrame;
    import javax.swing.JTable;
    import javax.swing.table.DefaultTableModel;
    public class TestCPUSampling {
        public static void main(String[] args) {
            EventQueue.invokeLater(new Runnable() {
                public void run() {
                    DefaultTableModel slowModel = new DefaultTableModel(5, 5) {
                        @Override
                        public Object getValueAt(int row, int column) {
                            try {
                                Thread.sleep(10);
                            catch (InterruptedException e) {
                                e.printStackTrace();
                            return super.getValueAt(row, column);
                    JFrame frame = new JFrame("Test");
                    frame.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
                    frame.getContentPane().add(new JTable(slowModel));
                    frame.pack();
                    frame.setLocationRelativeTo(null);
                    frame.setVisible(true);
    }Obviously Oracle should do something about that horribly slow Thread#sleep() method...
    But if your getValueAt() is called 15 million times, then it's more likely you have a loop like a TableModelListener which modifies the table model when the table model changes.

  • How to calculate the time between triggering the signal and receiving back

    i want the time elapsed between triggering the signal and receiving it back through a ultrasonic sensor in compactrio labview fpga.

    thank you sir for your reply, but im working on fpga target cRIO-9082 chassis it wont support those palletes , yah if i dont work on fpga target then i can use those palletes ....in attaching the vi for generating a digital pulse and acquiring it back but yrt dint got any idea hot to determine the time...if the vi is wrong please make the neccessary changes. i used this vi to determine the total time between trigger and receving signal of ultrasonic sensor.
    Thank you 
    Attachments:
    pulse generation.vi ‏51 KB

  • How to calculate the Current APC (Acquisition and Production Cost)

    Hi,
    Please help me how to calculate the Current APC.
    The Current APC (Acquisition and Production Cost) is a calculated value based on Previous Year Acquisition balance plus any value changes up to the time of the report.
    The Asset History Report (RAGITT_ALV01) calculates the Current APC value &
    The Current APC can also be found in the Asset Explorer (transaction code AW01N) under Country Book 10/ Posted Values tab then the line “Acquisition Value” and column “Posted values”.
    I suppose that the calculation of Current APC (Acquisition and Production Cost) is getting done in the GET statements in the report RAGITT_ALV01, but unable to find the actual logic.
    Please help me.
    Thanks in advance,
    Satish

    Hi,
    you'll find the logic in fm FI_AA_VALUES_CALCULATE
    A.

  • How to calculate the Current APC

    Hi,
    Please help me how to calculate the Current APC.
    The Current APC (Acquisition and Production Cost) is a calculated value based on Previous Year Acquisition balance plus any value changes up to the time of the report.
    The Asset History Report (RAGITT_ALV01) calculates the Current APC value &
    The Current APC can also be found in the Asset Explorer (transaction code AW01N) under Country Book 10/ Posted Values tab then the line “Acquisition Value” and column “Posted values”. 
    Thanks in advance,
    Satish

    Hi,
    I suppose that the calculation of Current APC (Acquisition and Production Cost) is getting done in the GET statements in the report RAGITT_ALV01, but unable to find the actual logic where it is being done.
    Please help me.
    Thanks in advance,
    Satish

  • How to calculate the quota base quantity in quota arrangement?

    Hi all,
    As we all know, when a new supplier is added in the quota arrangment, we take the help of quota base qunatity so that the new supplier does not get any unfair advantage over the existing suppliers. Would you please help me on how to calculate the quota base quantity or on what basis the quota base quantity is calculated?*
    Regards,
    Ranjan

    Dear,
    Quota arrangement divides the total requirements generated over a period of time among the sources of supplied by assigning a quota.
    Quota u2013 quota is equal to a number and its represents the proportionate of requirements. Total quota of all the vendors is equal to 100% of requirements.
    This quota arrangement is also specific to material and plant level.
    Quota rating = quota allocate quantity + quota base quantity / quota.
    Quota based quantity used only when a new vendor introduced.
    In the as on date situation, the minimum quota ratings will considered as preferred vendor.
    The 2 vendors has 2 same quota rating, the vendor who is having the highest quota will considered first.
    In the running quota, a new source of supply is included. (In situation of short supply) including a new source not means to reduce the quota for existing.
    Regards,
    Syed Hussain.

  • How to calculate the number of operations in Undo/Redo stack?

    How to calculate the number of operations in Undo/Redo stack?
    I tried to override UndoManager.pushUndo method and increment "operationsCounter" there, but pushUndo is called each time I make a change in text.
    Another idea was to override EditManager.finalizeDo and use "operationsCounter" there, but finalizeDo is private...
    Do you have any idea?

    Hi Richard,
    Thanks for the reply. I suggested that existed the more simple way to implement this

  • How to set the transition duration of a slide in keynote with applescript

    hi
    how to set the transition duration of a slide in keynote with applescript
    i made an applescript script which converts a numbers file to a keynote presentation
    figured out how to set the transitions but cant find how to set the time
    +set appTransition of slideTransition of current slide to "apple:dissolve"+
    anyone?

    you can send keystrokes to invoke menu commands via shortcuts but as for transition time not sure. You've check the dictionary right? Scripting support is very limited in KN.

  • Can I change the time/duration in a batch way instead of one by one?

    I am using Premiere Pro CS3 and I would like to have 7 seconds per photo and not the default of 5 seconds.  I know you can do each photo separately, by would love a batch performance.  Thanks,  Michele

    Thank you so much for your reply.  I really did not try your approach because I had the question posted on another thread, and was given the following reply and it worked; therefore, just for your information - here it is:
    Huntrex
    98 posts since
    Aug 4, 2009
    1. Jul 5, 2010 9:15 PM in response to: photomom17
    Re: How do I change the time/duration of all clips from the default 5 seconds?
    Go to: Edit -> Preferences -> General. Then customize the "Still Image Default Duration". To get seven seconds per image, enter 210 frames if the project is 29.97fps or 168 frames if it is 24fps.
    In the future you can post to this forum, for older versions of Premiere.
    It worked great!

  • How to Calculate the Actuall work days ....

    Hi Friends,
    how to calculate the Actuall Working days Based on the Joining date for 5day work and 6 days work?
    is there any FM to calculate this?
    Thanks in Advance,
    sudha.

    Hi Sudha,
    In your company , If they are maintaining Time Events then you can get the information of Employee's Presense or Absense from infotype 2011 (Time Events) and Absense from 2001 (Absense)..
    Also Consider Factory Calender for it.. and check out working days..
    Table TEVEN
    Try below FM as well..
    HR_DV_TIMEEVENTS_GET
    Hope it will solve your problem..
    Thanks & Regards
    ilesh 24x7
    ilesh Nandaniya

Maybe you are looking for