Date from DatePicker control


Posted by armin o - Feb 10 ’16 at 03:03

var d = fd.field('In_x0020_use_x0020_since').control('getDate');

gets me a:

Uncaught TypeError: Cannot read property 'toLowerCase' of undefined


Calling Value() returns a string, which is not what i need. I need the Date Object.


What am i doing wrong?



  • rostislav
    Member for: 4 years 11 months
    #1 by rostislav Feb 10 ’16 at 06:00

    I assume you're trying to do this on a Display form? On a Display form you are only able to get a string out any field field type, so if you need a Date object, you'll have to create it yourself. Exact code will depend on what culture format your date is in, but essentially it would be something like this:

    var parts = fd.field('In_x0020_use_x0020_since').value().split('-');
    var myDate = new Date(parts[0], parts[1]-1, parts[2]); // Note: months are 0-based
  • armin o
    Member for: 4 years 2 months 19 days
    #2 by armin o Feb 10 ’16 at 09:22

    Thank you. We are dealing with german and english date formats, so here is what i came up with..


    function asDate(dateString)


    var startDate = {};

    if (dateString.indexOf('.') != -1) {

    var d = dateString.substring(0,2);

    var m = dateString.substring(3,5)-1;

    var y = dateString.substring(6,10);

    var ho = dateString.substring(11,13);

    var mi = dateString.substring(14,16);

    startDate = new Date(y,m,d,ho,mi);

    } else



    var dps = dateString.split(' ');

    var dp = dps[0].split('/');


    var d = dp[1];

    var m = dp[0]-1;

    var y = dp[2];

    var ho = dps[1].substring(0,2);

    var mi = dps[1].substring(3,5);

    startDate = new Date(y,m,d,ho,mi);


    return startDate;


Displaying 1 to 2 of 2 messages