Announcement

Collapse
No announcement yet.

I am not using Date functions correctly

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • I am not using Date functions correctly

    When the following code is run against a daily one year bar chart the date, day, fullyear and month never change – whereas I was expecting the values to vary, depending on the bar date? The constant values returned are date=2, day=3, year=2008, month=3.
    Can you tell me the error of my ways? Thanks, Joe Miller

    -----------code snippet
    var todayX = new Date();
    MY_FUNCTION_output_debug_msg("115: todayX.getDate() = ",todayX.getDate());
    MY_FUNCTION_output_debug_msg("116: todayX.getDay() = ",todayX.getDay()); MY_FUNCTION_output_debug_msg("117: todayX.getFullYear() = ",todayX.getFullYear()); MY_FUNCTION_output_debug_msg("121: todayX.getMonth() = ",todayX.getMonth());

  • #2
    Re: I am not using Date functions correctly

    Joe
    They never change because you are retrieving the system time (ie the time of your computer) instead of bar time.
    A simple solution to what you want to accomplish is to build the date string using the day(), month(), year() functions rather than creating a date object (see the EFS KnowledgeBase for the description and syntax of these functions).
    If for whatever reason you instead need the date object and want to base it on bar time replace
    var todayX = new Date();
    with
    var todayX = getValue('time");
    Hope this helps
    Alex


    Originally posted by jcm21
    When the following code is run against a daily one year bar chart the date, day, fullyear and month never change – whereas I was expecting the values to vary, depending on the bar date? The constant values returned are date=2, day=3, year=2008, month=3.
    Can you tell me the error of my ways? Thanks, Joe Miller

    -----------code snippet
    var todayX = new Date();
    MY_FUNCTION_output_debug_msg("115: todayX.getDate() = ",todayX.getDate());
    MY_FUNCTION_output_debug_msg("116: todayX.getDay() = ",todayX.getDay()); MY_FUNCTION_output_debug_msg("117: todayX.getFullYear() = ",todayX.getFullYear()); MY_FUNCTION_output_debug_msg("121: todayX.getMonth() = ",todayX.getMonth());

    Comment


    • #3
      Thanks Alex

      Many thanks Alex.
      Super helpful.
      Bless You, You too are a Jolly Good Fellow, as I proclaimed Steve to be.

      Comment


      • #4
        Re: Thanks Alex

        Joe
        You are most welcome
        Alex


        Originally posted by jcm21
        Many thanks Alex.
        Super helpful.
        Bless You, You too are a Jolly Good Fellow, as I proclaimed Steve to be.

        Comment

        Working...
        X