Time calculation: type date or timestamp; how to calculate time in between?

Dear experts,
I like to create a simple flightbook table: FLIGHTID, TAKEOFFTIME, LANDINGTIME.
1. First question:
I prefer to use UTC as timezone in the app.
Which datatype would be best to take?
date or timestamp?
2. Secound question:
I like to calculate the flighttime between TAKEOFFTIME, LANDINGTIME?
How do I do this best?
Add a column flighttime?
How do I calculate the flighttime between TAKEOFFTIME, LANDINGTIME?
Advice and tips are very welcome!
Kind regards
Lorenz
--

Hi, Lorenz,
lokeller wrote:
Dear experts,
I like to create a simple flightbook table: FLIGHTID, TAKEOFFTIME, LANDINGTIME.
1. First question:
I prefer to use UTC as timezone in the app.
Which datatype would be best to take?
date or timestamp?Based on what you've said, I'd use DATE. DATEs are much more conveinet to manipulate than TIMESTAMPs.
TIMESTAMPs are good if you need fractipons of a second. For airplane flights, you probably don't even need seconds, let alone fractions.
TIMESTAMP WITH TIME ZONE is useful for multiple time zones. You're converting everything to UTC, so you don't need that.
2. Secound question:
I like to calculate the flighttime between TAKEOFFTIME, LANDINGTIME?
How do I do this best?
Add a column flighttime?No. Only consider adding a column if you're frequently filtering on flight time and need to index it. It's very rare when you need to do this. Normally, you just store the takeofftime and landingtime, and compute the flightime from these when you need to.
How do I calculate the flighttime between TAKEOFFTIME, LANDINGTIME?
landingtime - takeofftimeproduces a NUMBER, the number of days that landingtime is after takeofftime. You'll probably want the time in units of 1 hour or 1 mintue, not 1 day, so multiply that difference by the number of hours (as shown below) or minutes in a day:
SELECT     flightid
,     takeofftime
,     landingtime
,     (landingtime - takeofftime) * 24     AS hours_in_flight
FROM     flightbook
;

Similar Messages

  • How to calculate the ratio between the maximum and minimum peaks of the two waves using two while loops?

    hello everyone,
    i'm rai from indonesia
    I have a final project about pulse oximetriy, I have some problems,
    how to calculate the ratio between the maximum and minimum peaks of the two waves using two while loops to calculate SpO2 ?
    My program image can be seen below predicament ?
    Attachments:
    spo2 akusisi data with filter lpf hpf smoot nilai max min ir merah.vi ‏249 KB

    Hi Rai,
    You should post this into the LabVIEW forum rather than Real-Time since this isn't a Real-Time application. Your post will see more replies in the LabVIEW forum. 
    As far as your question is concerned, you can write the max and min from the respective loops to a local variable to send the data out of the loops to a third loop or just do the calculation in one of the loops. This would be ideal if you're trying to do this while the loop is running. 
    -Jayk
    Applications Engineering
    National Instruments

  • How to calculate the ratio between the maximum and minimum peaks of the two waves using two looping to find the value of SPO2?

    hello everyone,
    i'm rai from indonesia
    I have a final project about pulse oximetriy, I have some problems,
    how to calculate the ratio between the maximum and minimum peaks of the two waves using two while loops to calculate SpO2 ?
    My program image can be seen below predicament ?
    Attachments:
    spo2 akusisi data with filter lpf hpf smoot nilai max min ir merah.vi ‏249 KB
    spo2 akusisi data with filter lpf hpf smoot nilai max min ir merah.vi ‏249 KB

    Hi rai,
    I would appreciate it as kind of respect for forum participants if you would clean up your VI before uploading it (or images of its block diagram)…
    That being said:
    - Your inner while loops each run exactly twice. Replace them with FOR loops!
    - Lots of unneeded operations, mainly induced by ExpressVI usage. Is there a reason to convert to DDT and immediately convert back to 1D array?
    - You already calculate some Min/Max values. Ratio is just a division of two values…
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • MDX - how to calculate the sales between a certain period and the currentmember with a max date

    Hi all,
    1)I need to calculate the sales between W1 and the currentmember, but the max date should be W20. How can I solve this in MDX?
    MEMBER [Measures].[Q1 act.period to date sales] AS
    Sum(
    [Date invoice].[Bonus calendar - Week].[Bonus week of year].&[2015]&[1]
    [Date invoice].[Bonus calendar - Week].Currentmember
    *[CurrentSalesPeriod]
    ,[Measures].[Sales amount]
    This is the measure I have, I need to add the max date is W20. 
    2)Also, when I calculate the sales between [Date invoice].[Bonus calendar - Week].[Bonus week of year].&[2015]&[40] and the currentmember, for example being [Date invoice].[Bonus calendar - Week].[Bonus week of year].&[2015]&[20],
    he calculated the sales between this period. However, in theory this is not possible because W20 < 40. Is there any way I can put a constraint on this that he only calculates the sales if the currentmember is > the start period?
    Thanks in advance!

    Y, you can put a check on to determine if currentmember > start period.
    Firstly, your period keys are composite of year and period (indicated by the two ampersands in the fully qualified date above). If your period keys were non-composite (eg 201501) it would be a simple matter of 
    IIF([Date invoice].[Bonus calendar - Week].Currentmember.properties("key") > [Date
    invoice].[Bonus calendar - Week].[Bonus week of year].&[2015]&[1].properties("key"),[Measures].[Sales
    amount],null)
    There are advantages of having two period attributes on the dimension, one with a fully unique
    key and the other with just the period of fy, but that's digressing.
    With your composite keys, you could use a calc like the following for the SUM()
    Sum(
    [Date invoice].[Bonus calendar - Week].[Bonus week of year].&[2015]&[1]
    [Date invoice].[Bonus calendar - Week].Currentmember
    *[CurrentSalesPeriod]
    ,IIF([Date
    invoice].[Bonus calendar - Week].Currentmember.parent.properties("key") +[Date
    invoice].[Bonus calendar - Week].Currentmember.properties("key") > [Date
    invoice].[Bonus calendar - Week].[Bonus week of year].&[2015]&[1].parent.properties("key")+[Date
    invoice].[Bonus calendar - Week].[Bonus week of year].&[2015]&[1].properties("key"),[Measures].[Sales
    amount],null))
    Richard

  • How to calculate the difference between intdate and getdate

    Hi,
    My requirement is to get the data for all the claims where the difference between transactiondate and getdate() should be less than or equal to 7 which means any claims that happened in the past week.
    So, my query would be something like this
    select * from claims
    where transactiondate-getdate < 8
    But my transactiondate is in int format such as 20150331 and getdate would be in the format of 2015-03-31. Can someone please help me on how can i achieve the difference between these 2 date formats in the where clause.
    Please let me know if you have any questions or if i am unclear.
    Thanks

    Hi SqlDev12,
    Please find the below condition in your query,hope it would help you
    DATEDIFF(DD,CAST(CAST(TransactionDate
    AS
    VARCHAR)
    AS
    DATETIME),GETDATE())
    < 8
    Thanks & Regards,
    Praveena.

  • How to Calculate the Space between two Characters in GDI + ?

    I am Drawing the set of characters in Graphics, by Calculating the points using GraphicsPath for each Character. I Need to know how to calculate the distance should be given between the two characters?
    I am using this code to generate points
    PointF [] pnts;
    var p=new GraphicsPath();
    path.AddString("A","Arial",(int)FontStyle.Regular,50,new pointF(0f,0f),StringFormat.GenericDefault);
    Matrix m=new Matric(1,0,0,1,0,0);
    path.Flatten(m,1,0f);
    pnts=path.pathpoints;
    i am getting the points for all characters using the above code.
    Now i am combining the two character Using the points generated by the above code.  Eg "AB"
    Help me to calculate the the character space should be given between two characters?
    Thanks in Advance...

    Hi,
    this link can assist you:>
    Professional C# - Graphics with GDI+ 
    Mark as answer or vote as helpful if you find it useful | Ammar Zaied [MCP]

  • How to calculate the days between last movement of material till today date

    Hello Experts,
    Could someone help me please?
    I have a key figure in the InfoCube 0IC_C03 witch contain the last date of movement of material.
    (it is a key figure created in format date and contain the max value).
    How can I to calculate the number of days between this date (last movement),  till today date (system date).
    I need to show:
    material........last movement.....days without movements.
    xxxxxxxxxxx.....dd/mm/yyyy..........9999
    Im trying to do this calculation in bex using variable formula but it doesn't work becouse current date (customer exit) brings sy-datum in format yyyymmdd and the kf-last-mov is in format number (I dont know what kind of number)
    Thanks in advance,
    Points are assured.
    Regards,
    Silvio Meurer.
    Message was edited by:
            Silvio Meurer

    Hi Parth,
    Here we are using the version 7.0 and SP 10, I'm afraid I could not understand you. I Can't find the function DATE_DIFF (Where is it?)
    I'm using the formula and it doesn't work. Coud you see the result is:
    last movement date     Today date        result
    02.04.2007                  20.070.625       19.337.856
    18.05.2007                  20.070.625       19.337.810
    the "today date" is from customer exit and the result is a strange number to me.
    Could you help me?

  • How to calculate the difference between 2 different times being input.

    import java.io.*;
    import java.util.*;
    public class ClockingInOut
    public static void main(String[] args) throws IOException
    BufferedReader keyboard = new BufferedReader (new InputStreamReader (System.in));
    String input, input1, input2;
    int num1, num2, answer;
    System.out.println ("\t\t\tEMPLOYEE CLOCKING IN AND OUT SYSTEM!");
    do
    System.out.print ("\nWould you like to clock in and out? yes (y), no(n), ?: ");
    input = keyboard.readLine();
    if (input.equals("y"))
    System.out.print ("Please enter the hours you clocked in: ");
    num1 = Integer.parseInt (input1 = keyboard.readLine());
    System.out.print ("Please enter the minutes you clocked in: ");
    num2 = Integer.parseInt (input2 = keyboard.readLine());
    System.out.print ("Now Please enter the hours you clocked out! ");
    num1 = Integer.parseInt (input1 = keyboard.readLine());
    System.out.print ("And please enter the minutes you clocked out!: ");
    num2 = Integer.parseInt (input2 = keyboard.readLine());
    Hi people, i think my coding may be wrong. I would like the user to input the hours and then minutes of the time they clocked in and out of work. and then i want the program to be able to calculate the hours worked and print the mesage in the Command Prompt window.
    It's really confusing and hard, please help and provide me with the correct soure code if you can.
    Also, like in html how the notepad file has to have the opening and closing brackets, does java coding have something like this.
    Please reply. Thank You.

    hi
    check this java class
    import java.sql.Time;
    import java.text.ParseException;
    import java.text.SimpleDateFormat;
    import java.util.Calendar;
    import java.util.Date;
    public class util
        public static void main(String[] args)  throws Exception
            long t1 = getTimeOnlyLong();
            Thread.sleeo(2000);
            long t2 = getTimeOnlyLong();
            System.out.println(differenceBetween2Times(t1,t2));
        public static long getTimeOnlyLong()
            Date d = new Date();
            return d.getTime();       
        public static String differenceBetween2Times(long l1 , long l2)
            long diff = l1 - l2;
            System.out.println("differ =  " + diff);
            Date d = new Date();
            d.setTime(diff);
            SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss");
            return sdf.format(d.getTime());       
    }

  • How to calculate the difference between two dates?

    Hello,
    I would like to write some code which figures out how many days are between the Date_of_change (which is of datatype DATE, length 7 and of format DD-MON-YY) and the current date today. Then if the difference between Date_of_change and the current date is greater that 30 days for example then I would like to delete that record from the database.
    Thanks
    Doug

    Something like this should work:
    SQL> select * from emp order by hiredate ;
         EMPNO ENAME      JOB              MGR HIREDATE           SAL       COMM     DEPTNO
          7934 MILLER     CLERK           7782 21-OCT-2005       1300                    10
          7902 FORD       ANALYST         7566 22-OCT-2005       3000                    20
          7900 JAMES      CLERK           7698 23-OCT-2005        950                    30
          7876 ADAMS      CLERK           7788 24-OCT-2005       1100                    20
          7844 TURNER     SALESMAN        7698 25-OCT-2005       1500          0         30
          7839 KING       PRESIDENT            26-OCT-2005       5000                    10
          7788 SCOTT      ANALYST         7566 27-OCT-2005       3000                    20
          7782 CLARK      MANAGER         7839 28-OCT-2005       2450                    10
          7698 BLAKE      MANAGER         7839 29-OCT-2005       2850                    30
          7654 MARTIN     SALESMAN        7698 30-OCT-2005       1250       1400         30
          7566 JONES      MANAGER         7839 31-OCT-2005       2975                    20
          7521 WARD       SALESMAN        7698 01-NOV-2005       1250        500         30
          7499 ALLEN      SALESMAN        7698 02-NOV-2005       1600        300         30
          7369 SMITH      CLERK           7902 03-NOV-2005        800                    20
    14 rows selected.
    SQL> delete from emp where hiredate < sysdate - 30 ;
    10 rows deleted.
    SQL> select * from emp order by hiredate ;
         EMPNO ENAME      JOB              MGR HIREDATE           SAL       COMM     DEPTNO
          7566 JONES      MANAGER         7839 31-OCT-2005       2975                    20
          7521 WARD       SALESMAN        7698 01-NOV-2005       1250        500         30
          7499 ALLEN      SALESMAN        7698 02-NOV-2005       1600        300         30
          7369 SMITH      CLERK           7902 03-NOV-2005        800                    20
    4 rows selected.
    SQL>

  • URGENT..Date Query..How to Query Records created between 2 dates..

    Hi,
    I want to Query records which are created between 2 dates.
    I can use trunc(creation_date) this will give all the records for that day.
    I have to run a program every 15-20 minutes.
    following is an example
    example
    sysdate = 1/19/03 1:03:42 PM
    record1 creation date = 1/17/03 11:54:10 AM
    record2 creation date = 1/17/03 11:53:49 AM
    record3 creation date = 1/17/03 11:53:08 AM
    last resuest_date = 1/17/03 10:00:08 AM
    now i have to query records created between
    sysdate and last_request_date
    please reply ASAP
    Thanks
    Arun

    SELECT TO_CHAR(creation_date, 'DD-MON-YYYY') creation_date
    FROM navneet
    WHERE TO_CHAR(TO_DATE(creation_date, 'DD-MON-YYYY'), 'DD-MON-YYYY') BETWEEN
    TO_CHAR(TO_DATE('17-JAN-2003', 'DD-MON-YYYY'), 'DD-MON-YYYY') AND
    TO_CHAR(TO_DATE('20-JAN-2003','DD-MON-YYYY'),'DD-MON-YYYY');

  • How to calculate the difference between values in a custom PSObject?

    If I have a PSObject (created from an imported CSV) that has data like the following:
    date,Total size of files uploaded
    03-17-2014 09:08,1293334574547
    03-17-2014 09:10,1293335326912
    03-17-2014 09:13,1293336523562
    03-17-2014 09:14,1293337541156
    03-17-2014 09:16,1321031223511
    03-17-2014 09:16,1321032156844
    This CSV will have lines added to it, so the total number of lines will vary.
    Is there a way that two most recently added values and calculate the difference of the "Total size of files uploaded" values? 
    I have the columns properly cast as datetime and
    int64 already using this:
    $csv = Import-Csv $csvLocation |
    Where-Object { ![string]::IsNullOrWhiteSpace($_.datetime) } |
    Foreach-Object {
    $_.datetime = $_.datetime -as [datetime]
    $_."Total size of files uploaded" = $_."Total size of files uploaded" -as [int64]
    $_ }
     I tried searching thinking surely there must be someone else who has tried to do this" but I cannot find anything. I am just not sure how to approach this problem. Any help would be appreciated!

    Assuming all of your records are sequential with the last two being the most recent you could use this:
    $csv = Import-Csv $csvLocation |
    Where-Object { ![string]::IsNullOrWhiteSpace($_.datetime) } | select -last 2
    Foreach-Object {
    $_.datetime = $_.datetime -as [datetime]
    $_."Total size of files uploaded" = $_."Total size of files uploaded" -as [int64]
    $_ }
    $Difference = $csv[1]."Total size of files uploaded" - $csv[0]."Total size of files uploaded"
    This uses the index of the imported array and just the last two records.  Note that this will give a negative value if the total is less in the later record.  Hope this helps!
    You could also use 
    | sort datetime -ascending | select -last 2
    if they aren't already in order...

  • How to calculate any two date with diffence calculation by using obiee11g?

    Hi,
    i have a requirement like,
    location wise current month and previous month with movement calculation,can to tell me how to calculate any two date with diffence calculation
    by using obiee11g
    Note,
    I tried to implemented ago function as well as dynamic two dates calculation using $2-$1 methods..but i am getting the o/p it's self i am getiing some null value also that' why it's not tallying with our actual report.
    i tired to used ifnull(mesaurecolumn,0) also case condition on the mesaure colution still it's not tallying.
    THanks and Rds,
    Devarasu.R

    Hi,
    for Date Difference........
    TimestampDiff(interval, timestamp1, timestamp2)
    ex:TimestampDiff(SQL_TSI_DAY, cast('1-apr-2011' as date), current_date)
    Where:
    interval
    The specified interval. Valid values are: SQL_TSI_SECOND, SQL_TSI_MINUTE, SQL_TSI_HOUR, SQL_TSI_DAY,
    SQL_TSI_WEEK, SQL_TSI_MONTH, SQL_TSI_QUARTER, SQL_TSI_YEAR.
    Cheers,
    Aravind

  • Problem not seeing timestamp but variable of type date

    Hi everyone I am trying to do the tutorial @ http://www.oracle.com/technology/obe/ADF_tutorial_1013/10131/index.htm....
    But when I have generated my java objects from table, in my classe example ServiceRequest.java my variable requestDate is of type Date not Timestamp as said in the tutorial .... Will it have an effect on my application if i continue with Date or should i change it to Timestamp by using refactor...... Will it have any impact am new to TopLink here .. I have completed the srdemo tutorial using EJB 3.0 everything goes fine.,.....
    Can you help me please. Thank you for you help...
    Regards
    Lutchumaya

    Ok am sorry here is the link i have downloaded the tutorial.....
    http://www.oracle.com/technology/obe/ADF_tutorial_1013/10131/ADF_tutorial.pdf
    Yeah but i should get the variable of type Timestamp not Date as mentioned in the tutorial................
    Thank you for your quick reply Frank.
    Regards
    Lutchumaya

  • CONDITION BASE VALUE / ALT CALCULATION TYPE Pricing

    Dear All,
    I have a scenario where in I want the condition base value for calculating the value for a condition type to be based on
    Gross weight -  Net weight value of a material.
    Is it possible and if yse how do I acheive the same.
    Deepak

    Deepak,
    Alternative Calculation Type:
    Normally if you want to calculate a value you have to use a calculation type for determinating the value. This calculation type is either addition, subtraction or multiplication. Similarly SAP also has got a default calculation type in the control data of the condition type. There you have the options of either Qty based , Fixed Amount Based or Percentage based.  
    Here what happens is suppose if you define Your condition type that calculates the base price of a material on Qty based. Then the calculation will be done based on the quantity of the material. If the customer orders 10 Nos and you have maintained a unit price of 100 Rs for each material then the value determined is 1000 INR. Similarly if the discount condition type , you maintain the calculation type as %. This means if you maintain the value of 10  % in the condition record. Then this percentage is taken as the calculation type  and the condition value is determined.
    In some cases you have to forego the default calculation types and use the customer specific method for calculating a value. For ex if you are calculating the Freight charges for a Material . it depends on so many criteria like, the weight, volume  and also the minimum amount etc etc, in those cases, you forego the default value and then use the alternative calculation type in calculating the condition value against the particular condition.
    Alternative Condition Base value :
    If you have to calculate any value then you have to have a base value for it. For ex if you want to calculate the  discount of 10 % for a material then you have to have a base value on which this 10% is calculated. Normally you take the  condition value of the base price of the material to calculate the value.
    Now you don't want to take the base value and take other values as base value which are derived on some formulae. So you create a routine which will do the mathematical operations in the routine and derive you a value which is now used as the base value for calculating the condition value for a particular condition type.
    Reward poitns if u finds this helpful....
    Regds
    MM

  • Manual Excise condition type with calculation type as FIXED AMOUNT

    Dear Gurus,
    I have used a manual excise condition (JMAN) in my pricing procedure the difference is that I've changed its calcultaion type to FIXED AMOUNT.
    And in the same pricing procedure I have also got a percentage based Excise condition (ZEXC).
    And in any transaction either of the one that is JMAN or ZEXC will be used.
    The Manual Excise condition is used basically when the raw material sale takes place. The requirement is as such that they should be able to enter the duty value in INR and not in percentage. Please go through the example below
    *(For Example I am procuring raw material of 100 kg worth 10000 at 8% of excise duty. Excise duty will be 800 for 10000rs. So it will be 8 rs per KG.
    And now suppose I am utilizing 80 kg for production and want to sell remaining 20 kg. the Excise duty charged should be 160 rs. considering the rate per unit is 8rs.)*
    In this case user wants to enter the value in INR and not in percentage.
    And normally for the finished goods the percentage based condition is used.
    Now what my issue is that how will I copy the value from JMAN to ZEXC at the raw material sale. otherwise my finished good sales is happening without any problem.
    For this should I use any routine to copy the values from ZMAN to ZEXC??
    Or rather is it possible that I could copy values from a condition type whose calculation type is FIXED AMOUNT to other condition whose calculation type is percentage.
    How should I go ahead with this??
    Please guide me.
    Any answers??
    Cant Do it this way??
    Thanks & Regards
    Anand.k
    Edited by: anand k on Jul 8, 2009 6:38 AM
    Edited by: anand k on Jul 8, 2009 1:04 PM

    Check the condtion value in condition type UTXJ . If the JMOD value is 10% of UTXJ then assessable value should have been maintained for the Material and Plant combination in J1ID. This is due to Routine 351 maintined in pricing procedure for the condition type UTXJ
    check and confirm
    Senthils

Maybe you are looking for

  • Business partner deletion  - master data

    In  SAP Note 1111635 -Business partner cannot be deleted try to delete a business partner or a contact person. This is not possible bcoz address cannot be deleted because there are other references . 1) deletion of the address, because it used to be

  • PDF Printing Issue (Converting to Spool and back to PDF)

    Hi, I have a document which has minimum of 25 pages. This document is designed using BSP. When i print this document in DEV this is printed without any issue, but when we print in QA this doesn't print and keeps going on and on and finally we get ses

  • GUI_DOWNLOAD - number type fields

    Hi, I am using GUI_DOWNLOAD to download data. Before the download, the fields have padded zeroes i.e. (customer) 0000000006. After the download the padding is missing. I need the padded fields. Any ideas. Thanks Leanne

  • Unusually high CPU usage

    Looking at Activity Monitor it says % User 50-55, but adding up the cpu usage for the individual processes only totals 10-15%. It's running hot and the fans are fast and loud. Any idea why this is happening? This just started recently, I thought it w

  • Trying to update my 5800

    For 3 hours I'm trying to update my 5800. Tried with OVI suite, no luck, moved to PC Suite, again, no luck. 30 times. This is absolutely ridiculous, can't Nokia make it harder? Or, maybe, don't provide updates at all? This way, I spent half of my day