I want to do calculation between date/time fields

Post Author: fmonsma
CA Forum: Publishing
Hi, I already post this question a couple of times but I can't make it work.
IST:I  have converted a date/time field to a field so i can make calculation on it but i don't know ho to convert it to minuts;seconds.
Starttime        - Endtime           - Convert begin - Convertend - convertsumbegin - convertsumend - difference between31-7 12:39:00 - 31-07 13:08:00   - 123900    -    010800 - 123.900 - 10.800 -  -113.100
SOLL
Start time - Endtime - Differencebetween12:39 - 13:08 - 0:29
If i make this calculation in Excel it's very simple and works perfect. I want this in my Webintelligence report but don't know which functions/script i need to have. Thanks;

Post Author: jsanzone
CA Forum: Publishing
fmonsma:
Based on the sample data that you provide, it appears that you want to be able to report data based on the number of minutes that have elapsed between "Starttime" and "Endtime".  Looking at the WebI Variable Editor functions in the "Date & Time" functions list, it does not appear that there are any capability to determine elapsed minutes (it appears that the only "time" of the "Date & Time" functions is the "CurrentTime" function, not much else in regards to time...)
You don't mention the database platform you are using, however, if you happen to be using MS SQL Server, then they have the DATEDIFF function.  Within DATEDIFF the parameters are: DATEDIFF ( datepart , startdate , enddate ), where datepart specificies any of the following facts:  Year, quarter, Month, dayofyear, Day, Week, Hour, minute, second, millisecond
Bottom line, you will most likely not be able to rely on WebI to determine the elapsed seconds and you'll have to set up an object within your Universe to do the work on the database server and bring it across to your reports that way.

Similar Messages

  • Adding Date/Time Field + X Number of Days - Basic Calculation Question

    I am assuming this is a basic calculation question. New to Adobe LiveCycle Forms.
    I have a simple form containing a table. The table appears as such:
    Text
    Formatted as Date/Time Fields
    Header 3
    Monday
    user wil choose the beginning date (Date/Time) this is DateTimeField1
    Tuesday
    this should calculate DateTimeField1 + 1
    Wednesday
    this should calculate DateTimeField1 + 2
    Thursday
    this should calculate DateTimeField1 + 3
    Friday
    this should calculate DateTimeField1 + 4
    Saturday
    this should calculate DateTimeField1 + 5
    Sunday
    this should calculate DateTimeField1 + 6
    Calculations are performed after the date is chosen for Monday. My mind tells me the simple calculation of DateTimeField1 + 1 is not going to work (and in fact doesn't!) as it needs to change Monday to a number first. I saw on another thread the following:
    Num2Date(Date2Num(Date(DateTimeField1), "DD.MM.YYYY")+7, "DD.MM.YYYY")
    Thought this was going to get me close. No cigars though!
    Any quick help is greatly appreciated. And since I am new to this, details about what needs to be changed would be great too!
    Thanks

    Here an addition for you date field.
    This FormCalc script in the exit:Event will check it the selected date is on a monday.
    If not it will go the days back until the last monday.
    var Selection = Date2Num($.formattedValue, DateFmt(2))
    var WeekDay = Num2Date(Selection, "E")
    var NewDate
    if (WeekDay eq 1) then
              NewDate = Selection - 6
    elseif (WeekDay eq 3) then
              NewDate = Selection - 1
    elseif (WeekDay eq 4) then
              NewDate = Selection - 2
    elseif (WeekDay eq 5) then
              NewDate = Selection - 3
    elseif (WeekDay eq 6) then
              NewDate = Selection - 4
    elseif (WeekDay eq 7) then
              NewDate = Selection - 5
    else
              NewDate = Selection
    endif
    $ = Num2Date(NewDate, "EEE DD.MM.YYYY")
    Hope this helps, too.

  • How do you calculate difference in time (hours and minutes) between 2 two date/time fields?

    Have trouble creating formula using FormCalc that will calculate difference in time (hours and minutes) from a Start Date/Time field and End Date/Time field. 
    I am using to automatically calculate total time in hours and minutes only of an equipment outage based on a user entered start date and time and end date and time. 
    For example a user enters start date/time of an equipment outage as 14-Oct-12 08:12 AM and then enters an end date/time of the outage of 15-Oct-12 01:48 PM.  I need a return that automatically calculates total time in hours and minutes of the equipment outage.
    Thanks Chris

    Hi,
    In JavaScript you could do something like;
    var DateTimeRegex = /(\d\d\d\d)-(\d\d)-(\d\d)T(\d\d):(\d\d)/;
    var d1 = DateTimeRegex.exec(DateTimeField1.rawValue);
    if (d1 !== null)
        var fromDate = new Date(d1[1], d1[2]-1, d1[3], d1[4], d1[5]);
    var d2 = DateTimeRegex.exec(DateTimeField2.rawValue);
    if (d2 !== null)
        var toDate = new Date(d2[1], d2[2]-1, d2[3], d2[4], d2[5]);
    const millisecondsPerMinute = 1000 * 60;
    const millisecondsPerHour = millisecondsPerMinute * 60;
    const millisecondsPerDay = millisecondsPerHour * 24;
    var interval = toDate.getTime() - fromDate.getTime();
    var days = Math.floor(interval / millisecondsPerDay );
    interval = interval - (days * millisecondsPerDay );
    var hours = Math.floor(interval / millisecondsPerHour );
    interval = interval - (hours * millisecondsPerHour );
    var minutes = Math.floor(interval / millisecondsPerMinute );
    console.println(days + " days, " + hours + " hours, " + minutes + " minutes");
    This assumes that the values in DateTimeField1 and DateTimeField2 are valid, which means the rawValue will be in a format like 2009-03-15T18:15
    Regards
    Bruce

  • Problem with Date/Time field in Adobe LiveCycle

    I am trying to create a form that has a check-in and check-out dates. I want the user to enter those dates and then have the form automatically compute how many nights the user intends on staying.
    I have two fields, CHECKIN and CHECKOUT, set up as text fields. My third field, NIGHTS, has the following script to do the calculation:
    var strStart = CHECKIN.rawValue
    var strEnd = CHECKOUT.rawValue
    if(strStart.length && strEnd.length)
    var dateStart = util.scand("mmm d, yyyy",strStart);
    var dateEnd = util.scand("mmm d, yyyy",strEnd);
    var diff = dateEnd.getTime() - dateStart.getTime();
    var oneDay = 24 * 60 * 60 * 1000;
    var days = Math.floor(diff/oneDay);
    this.rawValue = days;
    else
    this.rawValue = 0;
    NOW...this is fine if the user inputs a four-digit year. If not, it's trouble. SO, what I want to do is change the CHECKIN and CHECKOUT fields to the date/time field so they select the date off the pop-up calendar.
    When I make the changes, I can't get the script to work for the NIGHTS field.
    CAN ANYONE HELP THIS NEWBIE?

    Make sure the format of the date strings provided by the calendar is what you are expecting. Or use the "formattedValue" for the input strings.

  • Add 1 hour to date/time field in list

    I need some help understanding the Date/Time fields in SharePoint Online. I've created a list with 2 date/time fields... StartDate and EndDate. I want the StartDate field to default to the current date/time. I want the EndDate field to default to the current
    date/time + 1 hour. I've tried numerous formulas in the default calculated value for these fields, and couldn't get it right. I finally got it, but I don't understand why. Here is the scenario:
    ***Note: Time Zone is set to UTC+5 (EST). Current Time is 8:45am
    Attempt 1:
    StartDate - Selected "Today's Date" for the Default Value
    EndDate - Selected "Calculated Value" for the Default Value. Entered the formula
    =now()+TIME(1,0,0) 
    Actual Results - StartDate: 5/28/2014 9:00am  EndDate: 5/28/2014 6:45am
    Attempt 2:
    StartDate - Selected "Calculated Value" for the Default Value. Entered the formula
    =now()
    EndDate - Selected "Calculated Value" for the Default Value. Entered the formula =now()+TIME(4,0,0) 
    Actual Results - StartDate: 5/28/2014 5:45am  EndDate: 5/28/2014 9:45am
    Attempt 3:
    StartDate - Selected "Calculated Value" for the Default Value. Entered the formula =now()+TIME(3,0,0)
    EndDate - Selected "Calculated Value" for the Default Value. Entered the formula =now()+TIME(4,0,0) 
    Actual Results - StartDate: 5/28/2014 8:45am  EndDate: 5/28/2014 9:45am
    So on attempt 3, I finally got the results that I was looking for. However, I don't understand a couple things:
    1. Why does selecting "Today's Date" for the default value, not select the current time?
    2. Why do I needed to offset the hours by 3 to get the current time?
    Thanks in advance,
    cflbasser

    The now function in my environment gives me the time in which the server is housed. If I change the regional settings it does not have an effect on the time. I'm guessing this means that your server is hosted in the UK or somewhere near there and the regional
    settings don't have an effect.
    Andy Wessendorf SharePoint Developer II | Rackspace [email protected]

  • How to find differene between two time fields??

    Hi Experts,
    I am trying to find difference between two time fields,  I have created two formula variables by using replacement path for the two time fields, I have taken dimension key NUMBER, because of this time format is converting to numbers for example if the time is 13:20:10 then it is converting to 1,32,010 then it is calculating, I am getting wrong values.
    Is there any options to find out the difference between two time fields.
    Thanks in advance,
    Venkat.

    use COPF_DETERMINE_DURATION. Its better you do it in data model itself.
    If you have date and time seperately use command
    use CONVERT TIMESTAMP command and
    then use this function module to get the difference in
    timestamp
    CCU_TIMESTAMP_DIFFERENCE
    us this in conjunction with the below function module
    DAYS_BETWEEN_TWO_DATES
    Edited by: Ananda Theerthan on Jan 21, 2010 7:18 AM

  • How not to insert a Date/Time field on INSERT

    hi all, i have a MSAccess table which has a lot of fields one of which is a date/time field......
    when i run the SQL code to insert values into this table i want the date/time field to be left blank.....
    i have tried to insert a blank space using '' but it shows the error
    SQLException: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
    does anyone know how i can overcome this problem.....?

    that worked thanks a lot,
    the values are inserted into the database now but i still get an error
    SQLException: [Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
    but the values are inserted....a bit confused about that any reason why that would happen?

  • How to compare Date in the TextField or DateTime with Date/Time field?

    Hi All,
    I am facing an issue with respect Date comparinson. I tried to look into entire discussions but failed to get the answer.
    My issue is: I wanted to comparet Date/time field value with Date value which is in TextField.
    The functionality of my form is:
    I have dropdown list which lists the registered customer ids binded to XML Datasource. On selection of the customer id from the dropdown I am displaying customer registration date in the TextField or say Date/Time field as below code in dropdown change event.
    RegistrationDetails.PurchaseEntry.txtRegDate.rawValue = regDataNode.CREATION_DATE.value; (this is TextField control)
    In form I have an Date/Time field in which use will select the date of item purchase. In the validation part I want to make sure that, the purchase date selected in Date/Time field must be greater than the Customer Registraiton Date. I able to compare if the customer selects the date from two different Date/Time fields. But how to compare the dates which one is in Date/Time field and Date is in TextField?
    I have tried using Num2Date and Date2Num with "YYYY-MM-DD"  format to compare but not succeed!
    Can you guys help me in this? Thanks in advance
    Regards.

    Hi,
    Yes, I am able to display the date which I have assigned to the text box. In the message box it show the value as '31/05/2009', since in this format i am assigining the date in the text box.
    Here is the code which I am assigning the value:
    RegistrationDetails.PurchaseEntry.txtRegDate.rawValue = regDataNode.CREATION_DATE.value;
    Do I need to change the format while assigning value in text box?
    You have told that, you have attached your test form, nothing is the reply. Can you repost the file?
    Regards.

  • Automatically displaying date and time in a date/time field on form initialize

    Good day all;
    I am trying to have the current date and time automatically be generated in a “date/time” field when the form is opened.
    I went through the forum and found an entry from Srini “ xfa.host.messageBox("" + Date());” . Of course this brought up a system message box with the date and time.
    I then tried “DateTimeField1.rawValue = (“”+date())… This also gave me a system message box with the date and time…
    Please let me know where I am going wrong
    Chomp

    Found the answer... And yes... in was in the "help" section... What can I say I was making it a lot more crazy than I needed to.
    You can use a date/time field to automatically show the current date by using the Runtime Property option in the Value tab of the Object palette.
    When using a current date field, the date updates to reflect the system’s current date each time a user opens the form.
    1.
    In the Library palette, click the Standard category and drag a Date/Time Field object onto the form design.
    2.
    In the Object palette, click the Value tab and select Calculated - Read Only from the Type list.
    3.
    Select the Runtime Property option.
    4.
    View the form in the Preview PDF tab.

  • Date/Time field format not wysiwyg

    I have a date field in my form that I formatted as m/d/yyyy hh:mm.  I thought that because it formats that field in that way my script would get passed down that way however it is not.  I want to manipulate it so the value is in the format I want it to be....
    I enter this in the date/time field: April 1, 2011 1:40PM
    When I click out of the field and I see: 4/1/2011 13:40
    Then I have a script that uses this field to make the file name but because I have a comma in there it will not save, if I take the comma out it will save.  So the main question is how do I format my field to pass down the value that I am seeing not the value that I am typing in.  You will notice I have a replace in there but I can't account for the comma because it reads it as part of the syntax.
    // Get the field value
    var dtentered = getField("datetime").value;  
    //replace any odd characters that will not allow the file to save
    var fdt = dtentered.replace(/[!@#$%^&*()+=|\:;"'<>?/{}]/g,"_");  
    // Specify the folder
    var fldr = "/c/WO Completed/";
    // Determine the full name and path
    var fp = fldr +  fdt + ".pdf";

    Thanks for the response...I'm not sure that I understand what you mean back-slash...I went ahead and did this but now it is giving me an odd file name
    // Get the field value
    var dt = getField("datetime").value;
    var mydt = escape(dt);
    //replace any odd characters that will not allow the file to save
    var fdt = mydt.replace(/[!@#$%^&*()+=|\:;"'<>?/{}]/g,"_");
    // Specify the folder
    var fldr = "/c/WO Completed/";
    // Determine the full name and path
    var fp = fldr + fdt + ".pdf";
    Returns a file name as
    April_201_2C_202011_201_3A40PM.pdf
    I was looking more for
    4_1_2011_13_40.pdf
    or
    April_1_2011_1_40PM.pdf

  • Default time in Date time field

    Hi,
    I have a date-time field. I want to default the time when a user selects the date.
    Currently when a user selects the date its takes the current system time. i would like it to take the time as 11:00.
    Can you please help me on this.
    Regards,
    Boris

    Hi,
    Check below links:
    Time picker along with Date picker
    Time as User input
    --Sushant                                                                                                                                                                                                                                                                                                                                                                                   

  • CDHDR date/time fields vs. changenr field - what's the proper order ?

    I have an application where I need to keep track of all the changes on sales orders.  Got it working pretty well, but in production it has the nasty habit of missing some changes ( it runs every 15 minutes and keeps track of the last date/time of an item it picked up ).  What's worse is that if I do a full run from scratch, the missing stuff appears.
    I think my algolrithim is flawed because of the missing things plus I found two entries who's entries look like the following (all in VERKBELEG) - yes, this is REAL data from my production system:
    changenr          udate     utime
    0004520883     2/27/2007     19:20:24
    0004522894     2/27/2007     19:16:31
    Apologies for the formatting - anyways, as you can see - which entry happened first?  Is the changenr field the authority on that or is the date/time fields ?  I have to think it's changenr because of the following:
    1 - changenr is part of the primary key - date and/or time is not
    2 - my program is missing changes
    What's even wierder is that the above two changes were made by the same person - and I have no idea which one they did first.
    bottom line - what determines order of changes ? - field changenr or date/time fields (which are udate and utime respectively).  I thought when I designed this the first time that it would been entry #2 above, but now I'm thinking it's entry #1.

    Tom;
    Thank you very much for the information - I did run transaction SNRO and I see on my dev box that it's buffered ( 10 numbers ).  This then leads to my next set of questions:
    1 - If you have multiple app servers and it's bufferered, where does it buffer ?
    2 - Are the change numbers still in order of the changes ( see #4 below ) ?
    3 - When a change number is buffered - does that mean the entire change is buffered or does that mean that only the number is buffered ?
    4 - If you have multiple app servers with multiple changes - do the changes appear in the database in order of the change numbers or out of order ?  Here's a simple example:
        change 1 - done by app server 1
        change 2 - done by app server 2
        change 3 - done by app server 1
        change 4 - done by app server 1
        change 5 - done by app server 2
    At any point, would I see any change number in the database which has a higher change number than one that doesn't yet exist in a commited form in the database ?  In order words, if I did the read just right, would I see changes 1,3,4 on one read and then 15 minutes later 1,2,3,4,5 ?  The reason I'm asking is because if you want to remember where you last left off, if a change number "appears" later and not in order, tracking the change numbers won't help either.

  • Issue: format / "language" of current Date (in date/time field), javascript only

    Hi,
    I have 2 date fields in my form, which should display the date in differnt format. (yyyy.mm.dd /  dd-mm-yyyy)
    To get the current date I use java script only
    Formular1.p1.date_YYYYmmDD::initialize - (JavaScript, client)
         var date = new Date();
        this.rawValue  =  date.toLocaleDateString();
    My first problem is (red): I get date in English, but I want it in a different language. As it was set in form settings
    My second issue is: how can I format a date/time-filed (not a text field) in javascript with a specific pattern on init-event?
    It seems my code in init-event overrides the pattern configuration of the date/time-field
    Here is my form, if anyone want to check it:
    https://acrobat.com/#d=zeOMyj9MhBdYbVWk8S1pHw

    Hi,
    I think both problems are the same, when setting a date/time field using the rawValue the format always has to be yyyy-mm-dd, if you use any other format the value is just treated as text and displayed without formatting.  
    var date = new Date();
    this.rawValue = util.printd("yyyy-mm-dd", date);
    You can also set the formattedValue if you have a date in the correct format. 
    var date = new Date();
    var currentLocale = xfa.resolveNode("#localeSet.#locale").name;
    var dateFormat = "date("+currentLocale+"){DD MMM, YYYY}"
    this.formattedValue = util.printd(dateFormat, date, true) 
    This code assumes the display pattern is date{DD MMM, YYYY}
    The date format specification is in the XFA Spec http://partners.adobe.com/public/developer/xml/index_arch.html
    Regards
    Bruce

  • Calculate one month prior to user entered date by a Date/Time field

    Hi All,
    I am currently pretty new to Live cycle and have no idea about Java scripting, i have been using this site a lot for my forms and have used the FormCalc for expanding tables and so on but this one is proving difficult. I am currently designing a form that requires a calculation of one month prior to a user entered date by a Date/Time field. I have looked at multiple posts on how to do this but none have worked (they are using the Date2Num).
    Is anyone able to enlighten me please?
    I currently have:
    Date/Time field Date Due
    Date/Time field Planned Date of Review
    I need Planned Date of Review to be calculated to be 30 days prior to Date Due. How do I go about doing this? Is it incorrect to use a Date/Time field as the field type for the calculation?
    Cheers
    Brad

    You can use FormCalc to compare the user input.
    Put this script into the exit:Event of the date field.
    if (Date2Num($.formattedValue, "MM/DD/YYYY") ne date()) then
    $host.messageBox("The entered date is not todays date!")
    endif

  • Distinct count on date/time field...

    Hi,
    I am trying to a distinct count on this formula that takes a date/time field and converts it to a date in order to get a distinct count of dates.  However, it's not working... say, if I have two dates are the same (the times may be different), it's counted twice.  Any suggestions?  I tried to convert this to a string thinking the evaluation may change, but no dice.  Thanks!!
    if not isnull({AVAILABILITY.PAT_ENC_CSN_ID}) then
        cstr(cdate({AVAILABILITY.SLOT_BEGIN_TIME}))
    else

    You can use the following formula...
    DateAdd("d", DateDiff("d", #1/1/1900#, {TableName.YourDateTimeField}), #1/1/1900#)
    This will set each date value to 12:00 am of it's respective day...
    So 8/16/2010   3:01:20PM would become 8/16/2010  12:00:00AM
    Now you can group on this formula field and then simply do a count on the date at the appropriate group level.
    HTH,
    Jason

Maybe you are looking for