Calculations with date fields

I'm trying to do a basic calculation with a CRM date form in BC.
I have a form field 'dateJoined' (though this could easily be the standard DOB field for the sake of this exercies) and I need to use javascript to calculate how many days have passed between today's date and the date in 'dateJoined'.
The {module_customerfield} outputs a string, not a date object, which would be fine but the format of the string is not compatible with the .date object.
I started down the path of lengthy substrings > variables, then linked variables > date object but after lines and lines of code, wondered if there was a simpler way that I was overlooking??

I'm trying to do a basic calculation with a CRM date form in BC.
I have a form field 'dateJoined' (though this could easily be the standard DOB field for the sake of this exercies) and I need to use javascript to calculate how many days have passed between today's date and the date in 'dateJoined'.
The {module_customerfield} outputs a string, not a date object, which would be fine but the format of the string is not compatible with the .date object.
I started down the path of lengthy substrings > variables, then linked variables > date object but after lines and lines of code, wondered if there was a simpler way that I was overlooking??

Similar Messages

  • Problem with date fields in where clause after changing driver

    Hi,
    We have changed the oracle driver we use to version 10
    and now we have some trouble with date-fields.
    When we run this SQL query from our Java program:
    select *
    from LA_TRANS
    where LA_TRANS.FROM_DATE>='20040101' AND LA_TRANS.FROM_DATE<='20041231'
    We get this error code:
    ORA-01861: literal does not match format string
    The query worked fine whit the previous driver.
    Is there some way I can run a SQL query with date fields
    as strings in the where clause?
    Thanks!

    Keeping the argument of standard SQL or not aside, comparing DATE columns to a constant string (which looks like a date in one of the thousands of the formats available, but not in others) is NOT one of the best programming practices and leads to heartburn and runtime errors (as you have seen yourself).
    I would rather compare a DATE to a DATE.
    Also, constants like that would be another issue to fix in your code:
    http://asktom.oracle.com/pls/ask/f?p=4950:8:6899751034602146050::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:528893984337,

  • Email Notification with date field

    Hi,
    i marked the a field as Display field this way it is displayed in the Email notification. (%Records%).
    But i can see the letral date field displayed in email as 2010:03:09:00:00:00:000
    Why is the ''00:00:00:000'' displayed when i have a date field??
    Did anyone face this issue..
    KR
    John

    HI John,
    Date field in MDM is 18 characters long and has date as well as time component to it.
    You can use assignment to trim this and transfer its value to another field and make that field as DF,so that it is displayed in the mail as date.
    Otherwise you can also create a calculated field for this purpose.
    Please go through this very useful link to create expressions/validations with dates:
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/b025fab3-b3e9-2910-d999-a27b7a075a16?quicklink=index&overridelayout=true
    Thanks,
    Ravi

  • Help with Date Field Value

    I have only used livecycle for a few months, so sorry if this questions seems basic, just beyond my knowledge at the moment.
    I need a little assistance with a date issue I am having on one of my forms.
    I have the display pattern of a date field set to --    date{MM/DD/YYYY}
    The issue I am having is some users are entering the date using the  " - "symbol instead.
    Example  01-01-2000
    and other are using the correct  01/01/00 format with the " / " as the divider.
    This is causing calculations in the next field to fail because the date it formatted incorrectly.
    How can I make the field convert the " - " to the the correct symbol of " / " and still allow others to use the " / " as they are now.
    Thanks

    I was able to figure it out using the edit pattern page

  • Problem with Date fields in Search panel

    Hi all,
    I use TP2 and in my jspx page I have a search panel with two date fields and table where the results is displayed. But there is a problem with these date fields, because when I search dates the results is nothing even I retype the date from table. Also I have other pages where this problem exist with same structure.
    Could somebody help me with some advice?
    Thanks in advance!

    Hi Frank,
    Thanks for the answer.
    I use the standart method to make search panel with drag and drop the data control to the page. The other search panel fileds work fine, only the date fileds are problem. Maybe something in view object doesn't work properly.
    Here I post the code from my page.
    <table border="1" style="margin:5px;">
    <tr>
    <td>
    <af:showDetailHeader text="ТЪРСЕНЕ" disclosed="true"
    inlineStyle="width:780px;">
    <table cellspacing="2" cellpadding="3" border="0">
    <tr align="left">
    <td align="right">
    <af:outputLabel value="#{bindings.EGN.hints.label}"/>
    </td>
    <td align="left">
    <af:inputText value="#{bindings.EGN.inputValue}"
    label="#{bindings.EGN.hints.label}"
    columns="#{bindings.EGN.hints.displayWidth}"
    maximumLength="#{bindings.EGN.hints.precision}"
    simple="true"/>
    </td>
    <td align="right">
    <af:outputLabel value="#{bindings.LNC.hints.label}"/>
    </td>
    <td align="left">
    <af:inputText value="#{bindings.LNC.inputValue}"
    label="#{bindings.LNC.hints.label}"
    columns="#{bindings.LNC.hints.displayWidth}"
    maximumLength="#{bindings.LNC.hints.precision}"
    simple="true"/>
    </td>
    <td align="right">
    <af:outputLabel value="#{bindings.AccPersonID.hints.label}"/>
    </td>
    <td align="left">
    <af:inputText value="#{bindings.AccPersonID.inputValue}"
    label="#{bindings.AccPersonID.hints.label}"
    columns="#{bindings.AccPersonID.hints.displayWidth}"
    maximumLength="#{bindings.AccPersonID.hints.precision}"
    simple="true"/>
    </td>
    </tr>
    <tr align="left">
    <td align="right">
    <af:outputLabel value="#{bindings.PersonName.hints.label}"/>
    </td>
    <td align="left" colspan="5">
    <af:inputText value="#{bindings.PersonName.inputValue}"
    label="#{bindings.PersonName.hints.label}"
    columns="#{bindings.PersonName.hints.displayWidth}"
    maximumLength="#{bindings.PersonName.hints.precision}"
    simple="true"/>
    </td>
    </tr>
    <tr align="left">
    <td align="right">
    <af:outputLabel value="#{bindings.DateFrom.hints.label}"/>
    </td>
    <td align="left">
    <af:inputDate value="#{bindings.DateFrom.inputValue}"
    label="#{bindings.DateFrom.hints.label}"
    simple="true">
    <af:convertDateTime pattern="#{bindings.DateFrom.format}"/>
    </af:inputDate>
    </td>
    <td align="right">
    <af:outputLabel value="#{bindings.DateTo.hints.label}"/>
    </td>
    <td align="left">
    <af:inputDate value="#{bindings.DateTo.inputValue}"
    label="#{bindings.DateTo.hints.label}"
    simple="true">
    <af:convertDateTime pattern="#{bindings.DateTo.format}"/>
    </af:inputDate>
    </td>
    </tr>
    <tr>
    <td align="right">
    <af:commandButton actionListener="{bindings.Execute.execute}"
    text="#{bundle.FindBtn_LABEL}"
    disabled="#{!bindings.Execute.enabled}"
    icon="/images/find.png"/>
    </td>
    <td align="left">
    <af:commandButton text="#{bundle.FindClearBtn_LABEL}"
    icon="/images/find_clear.png"
    action="#{PeopleBean.onClearVCBtn}"/>
    </td>
    </tr>
    </table>
    </af:showDetailHeader>
    </td>
    </tr>
    </table>
    Also I have a result table for the search panel, but I don't believe the problem can be there because it works fine when I search in fields different by inputDate.
    Do you have any suggestions?

  • Problem with Date-Field

    Hi,
    I have a problem with a date-field. Maybe I must describe the problem more detailled, but first I just want to ask you, if you know the following error-message: "21.10.2010 kommt nicht in der Menge der erlaubten Werte vor". I don't know the correct translation but it must be something like this: "21.10.2010 does not occur in the quantity of the permitted values". I don't find the position in the sourcecode of this message. And I know, that this message isn't thrown by a functionblock from SAP. So what is the describtion of this message?

    Yes I have a date field in my form. Ok I must describe it more detailled. I have an employee searchfield. After select an employee you see a form. After filling the form you click on "Send". It creates a ticket and sends the data to the Backend and jumps back to the employee search field. Untill this point everything works fine. There is no problem with the datefield. Now I want to create the form. I choose an employee and fill the form. But now it comes this message. But not after clicking the "send" button. The message comes after changing some data (e.g. change a radio button). So it looks like a validationproblem, but only at the second creationprocess. Maybe the first date is in some cache? I don't know...

  • Writing query to Oracle DB with DATE field in it.

    When I try to execute the following query on Oracle DB I get an exception. I know that the problem is with Date representation on the query string. Please, if anyone knows how to make it work help me.
    query = "INSERT INTO MYTABLE (NAME , BIRTHDAY ) VALUES ('" + person.getName() +" ' , " + person.getBirthday() + " )";
    statment.executeUpdate(query);
    getBirthday() returns java.sql.Date object.
    Please, please, help to work it out!

    Thank you, very much.
    I've put the record into DB!!!! Hurray!
    But now I have another problem. I've got a ResultSet & I'd like to extract the DATE from it. But how?
    The Exception text states that the name of the field (Birthday) is incorrect.
    My code:
    Date birthday = resultSet.getDate("Birthday");
    All other fields are perfectly well extracted, but they are Strings.

  • Error with date field when inserting records into sql server from webdynpro

    Dear SDN's,
    I am trying to insert the records into sql server through my webDynpro program.
    I have created a date field in a dictionary with the datatype date.
    In my webdynpro program to insert the date i am following the below format.
    String dateString = "2006/12/10";
          java.util.Date d=new java.util.Date(dateString);
          java.sql.Date <b>date</b> = new java.sql.Date(d.getTime());
    int i=stmt.executeUpdate("INSERT INTO TRAVEL_HEADER(TRQID,PROJECTID,<b>REQDT</b>,ADVCE,ETADV,PURTR) values(21, '555-1212', '" + <b>date</b> + "', 5000, '20060501','hi')");
    when i try to execute it, it gives the following error.
    <b>com.sap.sql.log.OpenSQLException: The SQL statement "INSERT INTO "TRAVEL_HEADER" ("TRQID","PROJECTID","REQDT","ADVCE","ETADV","PURTR") VALUES (21,'555-1212','2006-12-10',5000,'20060501','hi')" contains the semantics error[s]: - type check error: new value (element number 3 (CHAR)) is not assignable to column  >>REQDT<< (DATE)</b>
    Please correct me.
    Your help will be appreciated.
    Regards,
    Sireesha.B

    Hi,
    int i=stmt.executeUpdate("INSERT INTO TRAVEL_HEADER(TRQID,PROJECTID,REQDT,ADVCE,ETADV,PURTR) values(21, '555-1212', 'date', 5000, '20060501','hi')");
    try like this.
    I Think in SQL the general format to take date as input like this.
    INSERT INTO X VALUES ('10/30/56')
    thaks,
    Lohi.

  • MOdify with Date field giving error

    Hi,
    I have to modifuy an internal table using modify statement.
    After using the modify statement my date field in the internal table is replace by *.
    heres a sample code i have used to depict the scenario(with the test values:)
    DATA: BEGIN OF t_arcs_source OCCURS 0,
          premise(10) type c,
        key_date TYPE sy-datum,
      END OF t_arcs_source.
      DATA: wa_arcs_source LIKE LINE OF t_arcs_source.
    t_arcs_source-premise = '1001'.
    t_arcs_source-key_date = '20080101'.
    APPEND t_arcs_source.
    t_arcs_source-premise = '1001'.
    t_arcs_source-key_date = '20090101'.
    APPEND t_arcs_source.
      sort t_arcs_source by premise ascending key_date descending.
      clear t_arcs_source.
      loop at t_arcs_source into wa_arcs_source.
        at new premise.
           modify t_arcs_source from wa_arcs_source transporting key_date where premise = wa_arcs_source-premise.
        endat.
      endloop.
    please test the code and see the  error and help me out.
    Regards,
    Anand

    Hi.
    I have modify ur above given code and make it changed for ur need meanz according ur nedd and it is working accurately.
    check it and then tell me.
    DATA: BEGIN OF t_arcs_source OCCURS 0,
          premise(10) type c,
        key_date TYPE sy-datum,
      END OF t_arcs_source.
    " New code of loines i appended
      data: wa_t_arcs_source like t_arcs_source.
      data: t_arcs_source_1 LIKE STANDARD TABLE OF t_arcs_source WITH HEADER LINE.
      data: wa_t_arcs_source_1 like t_arcs_source.
    " End of new code of line
      DATA: wa_arcs_source LIKE LINE OF t_arcs_source. " I change this work area by wa_t_arcs_source
    t_arcs_source-premise = '1001'.
    t_arcs_source-key_date = '20080101'.
    APPEND t_arcs_source.
    t_arcs_source-premise = '1001'.
    t_arcs_source-key_date = '20090101'.
    APPEND t_arcs_source.
      sort t_arcs_source by premise ascending key_date descending.
      clear t_arcs_source.
      loop at t_arcs_source into wa_t_arcs_source. " Used the new work area
        wa_t_arcs_source_1 = wa_t_arcs_source.
        append wa_t_arcs_source_1 to t_arcs_source_1.
        at new premise.
           modify t_arcs_source_1 from wa_t_arcs_source_1 transporting key_date where premise = wa_t_arcs_source-premise.
        endat.
      endloop.
    Just copy paste in editor and check it.
    Edited by: tahir naqqash on Feb 2, 2009 11:24 AM

  • View criteria with date field in ADF

    Hi ADF Experts,
    I have a requirement like.I have a VO with query let say  "Select * from Employee"
    I have created viewCriteria in that VO like "HireDate between 'abc' and 'XYZ'.
    In AMImpl class I have written, one fuction to apply viewcriteria on VO and execute query.
    Expose that function as service method, and execution form backing bean.
    It is working properly for all other column except the date field.(May be beause of date format, as we cannot apply To_Char, or ToDate in view criterai for date format)
    Tried all possible combination but no luck
    Please help

    Hi,
    The below link might be helpful for you
    http://www.oracle.com/technetwork/developer-tools/adf/learnmore/59-table-filter-by-data-range-176653.pdf
    Thanks
    Prabhat

  • Materialized view fast refresh with date field

    I have a situation where I need to create a materialized view worth of 6 months of data with fast refresh option from the master table. Somehow whenever I have the where clause added with the date field then it craps out with "ORA-12015: cannot create a fast refresh materialized view from a complex query".
    Here is what I am trying to do. Please let me know if there is any other way to accomplish this.
    create table test (id number, date_time DATE);
    CREATE MATERIALIZED VIEW LOG ON test WITH ROWID;
    CREATE MATERIALIZED VIEW cms.scoreboard_statistics_mv
    BUILD IMMEDIATE
    REFRESH FAST
    WITH ROWID
    AS
    SELECT * from test
    WHERE date_time >= sysdate - 180;
    ORA-12015: cannot create a fast refresh materialized view from a complex query
    Thanks,
    Raj

    It's crazy but a new time Metalink help us into the Note:179466.1
    The restrictions that prevent snapshots from being fast refreshed depend on
    the version of Oracle being used, a full list of these by version is included
    in section 3. In all cases the snapshot defining query should:
    - refer to fully qualified table names rather than to partial table names.
    - refer to remote tables only, not to remote master views or synonyms.
    - not generate context sensitive data. For example, do not create a simple
    snapshot with a query that uses the SQL functions :SYSDATE, UID or USER.

  • Problem with date field (truncation)

    Hi guys!
    I have an interface between Oracle and Oracle. My LKM is SQL to SQL and my IKM is SQL Control Append.
    In the source table i have a date with a hour but after executing the interface in the target date field I receive only date without hour...
    Do you know where it can be truncated ?
    With regards,
    PsmakR

    This an Oracle JDBC Driver error...
    Try this to fix the issue:
    Go to Topology Manager and from the Physical Architecture > Technologies > Oracle > your Data Server > Properties tab, add the oracle.jdbc.V8Compatible property and set its value to true.
    Doing that you can loose the millisecond precision for timestamps format.
    You can also have a try with the Oracle JDBC Driver version 11.1

  • Working with Data Field (XMLTYTPE)

    XMLTYPE is a new type of data element I have yet to work with and I am seeking some guidance as how best to approach
    this in order to display the contents of these fields.
    I have the XSD available to me which I believe I will have to query the contents withing this field and within a outter query.
    This may not be an easy task to explain, but if some one is willing to take a stab at it, i'd greatly appreciate any advice given.
    Enjoy your Day,
    Sincerely,
    George

    Check this link
    http://docs.oracle.com/cd/B10500_01/appdev.920/a96620/xdb04cre.htm
    If helps pls mark

  • Can i Use a time stamp vale  in where condition with date field?

    HI,
    In a where condition the table field vale is of type timestamp and select options value is of type date.
    How do i select data?

    Define a range for r_dt for timestamp field.
    Initailize the range with the below values.
    r_dt-sign = 'I'.
    r_dt-option = 'CP'.
    concatenate r_date-low '*' into r_dt-low.
    concatenate r_date-high '*' into r_dt-high.
    append r_dt.
    Use r_dt in your select query where clause.
    Note - r_date is the select-option for your date field.
    Regards
    Anurag

  • Trouble to use COOIS with date fields

    Hi,
    Some trouble to use Tcode COOIS, which could provide a lot of information on Production Workflow. When
    indicating a date in one of the date fields, datas pulled do not fit with the criteria. For example, if the 08082011
    is entered, the report provides informations on postings created the 08082011 and lateru2026 Is there any idea to
    fix the problem or to understand why.
    Thks
    sb
    Edited by: STANISLAS BRESIN on Aug 25, 2011 11:46 AM
    Edited by: STANISLAS BRESIN on Aug 25, 2011 11:47 AM

    Hi,
    Please note that In COOIS, yes you donot have creation date / confirmation posting date.
    You can sort the production orders wrt basic start dates / finish dates.
    Select the basic start date column, rt click and click sort in ascending or descending order
    Refer the OSS note Note 434123 and 615206 - Filling and displaying own fields in information system
    Regards,
    sankaran

Maybe you are looking for

  • How do I pull just the year from a date?

    I'm trying to pull just the year from a date and cannot figure out how this can be done. I tried the SUBSTR fuction but its not acting how I would expect. What I'm wanting to do is write a condition that says Item Birth Year = Current Year minus 23 I

  • ISE 1.2.x Reporting Suppression: Good or Bad?

    Hello, I was wondering if most of you enable the ISE 1.2.x feature "Suppress Repeated Successful Authentications." (Administration/Settings/Protocols/Radius). At first blush this seems like a good thing as it cuts down the number of entries in the lo

  • What's new in Photoshop CC 2014.2.1?

    What's new in Photoshop CC 2014.2.1? Is this updater Macintosh version only?

  • Does iBooks Author support hebrew ?

    Can I write hebrew books using the iBooks Author ? Can I publish them to the app store ?

  • Color Palette Problem

    I'm somewhat new to Fireworks... I've been using it now for a few months, but here recently I've run into something I just can't figure out. It seems as though when I'm working with colors, I'm working with a smaller color palette than what I worked