Forum Discussion

joffre's avatar
joffre
Regular Contributor
13 years ago

Problems with aqDateTime

Function ActualDate

    fullDate =
aqDateTime.Today

    Log.Message(fullDate)

    tDay =
aqDateTime.GetDay(fullDate)

    tMonth =
aqDateTime.GetMonth(fullDate)

    tYear =
aqDateTime.GetYear(fullDate)

    dtAtual = tDay & tMonth & tYear

    Log.Message(dtAtual)

End Function




I have the code above.  My "fullDate" variable is returning the value "04/10/2011" and "tDay & tMonth & tYear" is returning "4102011".

The idea is to call this function from my Sub to fill some forms textBox; preventing me to edit my code every day and change the date manually.

One of my problems is that aqDateTime.GetDay is getting just the "4", and I need "04".

The other problem is that I have no idea about how to use this function in a Sub. I know that I have to make my function return the full date (without '/'), but how will I do that? I've tried the "Return variable" statement, but it didn't work.



Thanks.





Editing:

I also did as below, but my code got ugly and bigger, so I decided to do like I've showed before..

fullDate = aqDateTime.Today

dia_1 =
aqString.GetChar(fullDate, 0)

dia_2 =
aqString.GetChar(fullDate, 1)

Log.Message(dia_1&dia_2)

mes_1 =
aqString.GetChar(fullDate, 3)

mes_2 =
aqString.GetChar(fullDate, 4)

Log.Message(mes_1&mes_2)

ano_1 =
aqString.GetChar(fullDate, 6)

ano_2 =
aqString.GetChar(fullDate, 7)

ano_3 =
aqString.GetChar(fullDate, 8)

ano_4 =
aqString.GetChar(fullDate, 9)

Log.Message(ano_1&ano_2&ano_3&ano_4)

7 Replies

  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    Use aqConvert.DateTimeToFormatStr (http://smartbear.com/support/viewarticle/13451/)



    Here's how I would write it out to get the date in the format of ddmmyyyy without slashes.



    Function ActualDate

    ActualDate = aqConvert.DateTimeToFormatStr(aqDateTime.Today(), "%d%m%Y")

    End Function




    To use this then, you'd simply call ActualDate



    Sub Test()

    Log.Message(ActualDate)

    End Sub
  • joffre's avatar
    joffre
    Regular Contributor
    How will I set the value found on my Function to a TextBox?
  • joffre's avatar
    joffre
    Regular Contributor
    Thanks Robert!



    I know that is is basic on VBScript, but I didn't remember the sintax.
  • joffre's avatar
    joffre
    Regular Contributor
    Robert,



    I did as you told me to:

    Call Func.vsePanel_5.fraDummy_27.txtDatas_19.SetText(ActualDate)




    But it didn't work. I've received the following LogError Message:

    Type Message Time Link Unable to find the object SetText("10102011"). 9:35:38 


    I've right clicked on Log.Error result and copied the result...
  • tristaanogre's avatar
    tristaanogre
    Esteemed Contributor
    SetText is a method on the object type that I typically use.  In your case, the object my not support the "SetText" method.  You will need to find out what methods/properties are available on your object and use the appropriate method/property.


  • joffre's avatar
    joffre
    Regular Contributor
    Thanks Robert.



    It worked when I did like this:

    Call Func.vsePanel_5.fraDummy_27.txtDatas_19.Keys(ActualDate)