Forum Discussion

farhanahmed's avatar
farhanahmed
Contributor
14 years ago

System date is in other language than in tested App

Hi,



I am writing my script in Test Complete 8 by using VBScript.

I have a problem, i want to compare system date with the date in my application but the problem is that System date is in other language than English but date version in my Application is in English.

How can i solve this problem, is there any way to get the English version of the system date if its not in English?



-farhan

4 Replies

  • Anonymous's avatar
    Anonymous

    Hi Farhan,



    I suggest that you try using the Today method of the aqDateTime object to return the current date. Then, you need to specify the format in which the current date should be displayed. To perform the conversion, you need to use the DateTimeToFormatStr method of the aqConvert object. For example, you can use the following code:







      'Returns the current date

      today = aqDateTime.Today()

      'Specifies the format of the current date

      todayUSA = aqConvert.DateTimeToFormatStr(aqDateTime.Now(), "%m/%d/%y")

      'Outputs the result

      Log.Message("Now: " & todayUSA)







    Besides that, you can use the GetMonth, GetDay and GetYear methods of the aqDateTime object to accomplish your task. In this case, you can get the current month, day and year respectively and compose a string in the format you need to compare it with the date in your program. For example, see the code below:







      'Returns the current date

      today = aqDateTime.Today()

      'Returns the month number of the specified date

      Log.Message("Month: " & aqDateTime.GetMonth(today))

      'Returns the ordinal number of a day in a month

      Log.Message("Day: " & aqDateTime.GetDay(today)) 

      'Returns the year number of the specified date

      Log.Message("Year: " & aqDateTime.GetYear(today))

  • Hi

    im using "%dddd%mmmm%dd,%yyyy%hh:%nn%ampm" formate sting my objective is that it should display

    Month date,year time am/pm

    today = aqDateTime.Today()

    Log.Message aqConvert.DateTimeToFormatStr(today, "%mmmm%dd,%yyyy%hh:%nn%ampm")



    but when i run the script incorrect string formate error appears.

    would you please tell me how can i resolve this problem.

    -farhan
  • hi

    above problem is resolved.

    currently problem that i am facing is that ...my date time format on my application is as follows

    June 12,2012 1:13 PM-12 hour formate



    But system date time formate is as follows

    Juni 12,2012 13:13 -24 hour fomate and language of the months is Deutsch.



    When i convert the current date time with the following string

    Log.Message aqConvert.DateTimeToFormatStr(today, "%B %d,%Y %I:%M %p")



    it does not show the correct result.



    would you please tell me how can i solve this problem



    -farhan


  • Anonymous's avatar
    Anonymous

    Hi Farhan,



    The Today method of the aqDateTime object you used earlier returns only the current date. To obtain the current date, as well as the time, you need to use the aqDateTime.Now method. Also, I think that you will have to get back the name of the month in English, right? I've written a function that does this. Please see the following code:





    Sub Test

      'Returns the current date and time

      today = aqDateTime.Now()

      'Outputs the current date and time in the format you need

      Log.Message(MonthName(aqDateTime.GetMonth(today)) + aqConvert.DateTimeToFormatStr(today, " %d,%Y %I:%M %p") )

    End Sub





    Function MonthName(N)

      If N = 1 Then MonthName = "January"

      If N = 2 Then MonthName = "February"

      If N = 3 Then MonthName = "March"

      If N = 4 Then MonthName = "April"

      If N = 5 Then MonthName = "May"

      If N = 6 Then MonthName = "June"

      If N = 7 Then MonthName = "July"

      If N = 8 Then MonthName = "August"

      If N = 9 Then MonthName = "September"

      If N = 10 Then MonthName = "October"

      If N = 11 Then MonthName = "November"

      If N = 12 Then MonthName = "December"   

    End Function