Forum Discussion

Novari-QA's avatar
Novari-QA
Frequent Contributor
7 years ago

aqDateTime has AddDays and SubDays an interesting find

aqDateTime has two functions. When looking at the documentation for  aqDateTime methods, we dont see SubDays, but yet this function exsists. 

https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqdatetime/methods.html

If i type in aqDateTime.SubDays("01/02/2017", 1) you would expect the result "01/01/2017" but that isn't the case.

It seems as if aqDateTime.SubDays acts exactly the same as aqDateTime.AddDays. 

The result above will come out as "01/03/2017".

Very strange, i do not suggest using this feature as it does the same thing as add days when expected to do the opposite.

Yes i get that i can go AddDays (date, -1)

Just posting an interesting find

4 Replies

  • karkadil's avatar
    karkadil
    Valued Contributor

    Using undocumented features is always a risk. They may be used for internal needs only and you never know why and how.

     

    I remember a strange issue about TestComplete about 10 years ago, when it was impossible either to declare a variable MSG or to use it correctly. It was related to some internal variable with the same name.

    • tristaanogre's avatar
      tristaanogre
      Esteemed Contributor

      Actually, I just tried in TC 12.40 to use aqDateTime.SubDays... and I got an "unknown identifier" error.

      What version of TC are you using?

      • Novari-QA's avatar
        Novari-QA
        Frequent Contributor

        You know what, this is interesting. I was running the function through a script extension, no errors but treated it like AddDays.  HMMM

  • karkadil's avatar
    karkadil
    Valued Contributor

    LOL, the issue is still here :)

     

    Try running this code anywhere and you'll get JScript Runtime Error

    MSG = 'any text';
    function test1()
    {
      Log.Message(MSG);
    }

    Change the name MSG to anything else and it will work just fine :)