Results 1 to 4 of 4
  1. #1

    Converting date in data table


    I have seen some discussions that are close to my question, but none seem to answer my need. I hope someone here can.

    I am pulling a date value (a date of last SW update) from the database. It's in the form 10/29/04. I am using a database output value function. I then put this value into my data table under the parameter Update_Date.

    I need to compare this date to verify that it matches the "version date" in my Help > About menu. I use the Text Area Checkpoint function to get this, since it is in a GUI window.

    However, the date on the About menu is in the form 29-October-2004.

    Is there a way to convert the database (or About menu) value in order to compare them during testing? I can fiddle around with the data table outside of testing , but when executing the test, I cannot determine a way to get both dates in the same format in order to make sure the two match.

    Obviously, the long term fix may be to change the date format on the About menu to match the database value, but that's not an immediately available fix.


  2. #2

    Re: Converting date in data table

    Have you tried using TRUNC([tablename], 'DDD') = TRUNC (SYSDATE,'DD-MM-YY') in your sql query or dbms.output statement?
    I like what i know and I know what i like

  3. #3

    Re: Converting date in data table

    One easy way is with the FormatDateTime function in QTP. You could set your system date to a specific format that matches either of the dates you are trying to compare then use this function to format the other variable to the same format. Of course, this makes the script subject to failures if you try to run it on another machine without also formatting the system date on that machine first.

    A better way is to format it with the Day, Month, Year functions. Also WeekdayName and MonthName.

    versionDate = whatever
    databaseDate = whatever
    formattedDBDate = Day(databaseDate) & "-" & MonthName(Month(databaseDate), true) & "-" & Year(databaseDate)

    Then do your compare.

    Hope that helps. I also hope I got the syntax right...


  4. #4

    Re: Converting date in data table

    I would say convert your database and aboutdate value using Date function and then compare these values.

    </font><blockquote><font size="1" face="Verdana, Arial, Helvetica">code:</font><hr /><pre style="font-size:x-small; font-family: monospace;">If Date(DataBaseDate) = Date(AboutDate) Then
    End If</pre><hr /></blockquote><font size="2" face="Verdana, Arial, Helvetica">



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
BetaSoft Inc.
All times are GMT -8. The time now is 05:46 PM.

Copyright BetaSoft Inc.