Skip to main content

Search

Null DateTime Evaluations

Comments

5 comments

  • Christof

    Hi James Wake

     

    An empty DateTime field returns an object of type string - not a null object!

    Therefore you have to handle the input value like this:

    if (typeof [[Birthday]] !== 'string') {
       return [[Birthday]].Month;
    }
    return null;
    0
  • JamesW

    Thanks Christof,

     

    It still doesn't work. I try the code given but it Returns:

     

    Error: Error on evaluating statements: Line 37: Too many characters in character literal

     

    So I place string inside double quotes, and then receive the following:

     

    Error: Error on evaluating statements: Line 37: Syntax error, '(' expected Line 37: ) expected Line 37: Invalid expression term '=' Line 37: ) expected Line 37: ; expected Line 37: Invalid expression term ')' Line 37: ; expected

     

     

    0
  • Christof

    Hi James Wake

     

    Make sure you use Function code expression type.

    This works fine for me to get the month as number:

     

    if (typeof [[Birthday]] !== 'string') {
         return [[Birthday]].getMonth()+1;
    }
    return null;
    0
  • JamesW

    I'm am doing this in the Solution Studio in a Calculated Value Expression not in the Rich Forms.

    0
  • Christof

    This expression worked in my Background Calculation case without any issues:

    if([[Birthday]]) {
         return [[Birthday]].getMonth()+1;
    }
    return null;

    0

Please sign in to leave a comment.