Ask a Question

How to compare two date string in a date format

SOLVED
nedbacan
Contributor

How to compare two date string in a date format

  I have two captured date strings (see Object Spy screen) that I need to be compare and report to the log file,  if "date1" is greater than "date2"  the test pass and if not the test failed.  

 

See the screenshots below, the string date1 for image1 should be compared to the string date2 from image2, the expected result is that the newer image is displayed above the older image.  

 

Can someone show an example in Javascript how it should be written, learning from a sample is best  

 

I assumed the method aqConvert.StrToDateTime(S) should be used.

 

Compare.jpg

 

DATE STRING 1

Date1.png

 

DATE STRING 2

Date2.png

 

 

@BenoitB

1 REPLY 1
Marsha_R
Community Hero

Here's how to convert a string to a date using javascript

https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqconvert/strtodatetime.ht...

 

Here's how to compare the dates using javascript 

https://support.smartbear.com/testcomplete/docs/scripting/working-with/dates/javascript.html#Compari...


Marsha_R
[Community Hero]
____
[Community Heroes] are not employed by SmartBear Software but
are just volunteers who have some experience with the tools by SmartBear Software
and a desire to help others. Posts made by [Community Heroes]
may differ from the official policies of SmartBear Software and should be treated
as the own private opinion of their authors and under no circumstances as an
official answer from SmartBear Software.
The [Community Hero] signature is used with permission by SmartBear Software.
https://community.smartbear.com/t5/custom/page/page-id/hall-of-fame
cancel
Showing results for 
Search instead for 
Did you mean: