cancel
Showing results for 
Search instead for 
Did you mean: 

system date retrieve

Frequent Contributor

system date retrieve

i have written below code to retrieve the system date or records created date :6/13/2018 10:42:18 AM

 

var NowValue = aqDateTime.Now();
if("Created Date"==NowValue)
{ RowIndex7 = Grid.FindRow("Created Date", NowValue);
if (RowIndex7 != -1)
Grid.ClickCell(RowIndex7, "Created Date");

log,message ("row exists)

else log.error("row not found)

 

somehow the balove script doesnot picks the value and gives row not found. any suggestions

3 REPLIES
Community Hero

Re: system date retrieve

aqDateTime.Now() does not return a string... it returns an object type of DateTime...  So, to compare that to a string from a grid is a mismatched comparison.  you need to convert aqDateTime.Now() to the format that matches what you're looking for in your grid.  Use aqConvert.DateTimeToFormatStr to do so.


Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.


I’ll be talking about “Hidden Treasures – TestComplete Script Extensions” at #SBConnect in October! Who’s joining me? Click here for tickets
Extensions available
Frequent Contributor

Re: system date retrieve

Thanks Martin! but how can I specify AM or PM. Is there any way to format n specify AM and PM.

 

 var FormatStr = aqConvert.DateTimeToFormatStr(NowValue, "%#m/%#d/%Y %I:%M:%S")

 

Highlighted
Community Hero

Re: system date retrieve

Yes.  All format specifiers can be found at https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqdatetime/date-and-time-f...

 

Change your code to


var FormatStr = aqConvert.DateTimeToFormatStr(NowValue, "%#m/%#d/%Y %I:%M:%S %p")

Robert Martin
[Community Expert Group]
Please consider giving a Kudo if I write good stuff
----

Why automate?  I do automated testing because there's only so much a human being can do and remain healthy.  Sleep is a requirement.  So, while people sleep, automation that I create does what I've described above in order to make sure that nothing gets past the final defense of the testing group.
I love good food, good books, good friends, and good fun.


I’ll be talking about “Hidden Treasures – TestComplete Script Extensions” at #SBConnect in October! Who’s joining me? Click here for tickets
Extensions available
Top Kudoed Authors
Are You In?

Meet the Community Leaders!

SmartBear Connect is an excellent opportunity for training, in-person support, and networking.

GET YOUR TICKET WITH $100 OFF