cancel
Showing results for 
Search instead for 
Did you mean: 

how to get date value equal to today's date without timestamp from the Date column in a grid.

Frequent Contributor

how to get date value equal to today's date without timestamp from the Date column in a grid.

I was using below script findrow method to capture the date .any suggestions.

var dt = aqDateTime.Today();
var FormatStr = aqConvert.DateTimeToFormatStr(dt, "%#m/%#d/%Y")
Log.Message("Value of dt or Formated String --> " + FormatStr)
RowIndex = Grid.FindRow("Created Date",FormatStr);
for(i=0;i<= attributeMaintenanceGrid.wRowCount-1;i++)
attributeMaintenanceGrid.wValue(i, "Created Date");
Log.Message("Value of dt string --> " + "Created Date")

 

getting : value todays date is not found since date column considers timestamp too

and value doesnot return created date value. 

 

9 REPLIES 9
Community Hero

Re: how to get date value equal to today's date without timestamp from the Date column in a grid.

So... your column includes the timestamp?

 

What you're going to have to do is, instead of using the native FindRow, write your own for-loop to go through the rows on your grid and use an aqString.Find method on the current row to determine if the column contains the date.


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.

Mysterious Gremlin Master
Extensions available
Frequent Contributor

Re: how to get date value equal to today's date without timestamp from the Date column in a grid.

getting an error : aqString object  not found

 

for(i=0;i<= Grid.wRowCount-1;i++)
var i=Grid.aqString.Find("Created Date","FormatStr")
Log.Message("Value of dt string --> " + "Created Date")

Grid.wValue(i, "Created Date");
Log.Message("Value of dt string --> " + "Created Date")

Community Hero

Re: how to get date value equal to today's date without timestamp from the Date column in a grid.

aqString is not a child object of grid.


https://support.smartbear.com/testcomplete/docs/reference/program-objects/aqstring/find.html


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.

Mysterious Gremlin Master
Extensions available
Community Hero

Re: how to get date value equal to today's date without timestamp from the Date column in a grid.

Generally,in pseudoe code:

for all rows in the grid {
     var dateString = attributeMaintenanceGrid.wValue(rowIndex, 'Created Date');
     if (aqString.Find(dateString, FormatStr, 0, false) != -1) {
         var  foundRow = rowIndex;
         break;
     }
}

 

Basically, you're doing the loop through the grid, finding the row yourself.  Find does a "contains"... so, it will return a value >= 0 if it contains your date, otherwise it will continue the loop.  It exits the loop and the row you want is stored in the "foundRow" variable.

 

Note, the above code is NOT tested, NOT runnable, NOT accurate code... it's presented only to give example of how to do it.  It's up to the reader to make the proper edits and application for production use.

 

 


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.

Mysterious Gremlin Master
Extensions available
Frequent Contributor

Re: how to get date value equal to today's date without timestamp from the Date column in a grid.

how do you define rowIndex here?

Is it find row method, if I use Find row : value 6/14/2018 was not found in the created date column is seen 

Community Hero

Re: how to get date value equal to today's date without timestamp from the Date column in a grid.

How did you implement it?  What's your code?  As I mentioned in my post, what I posted was JUST to give the concept.  I can't debug your code if I don't know what you wrote.


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.

Mysterious Gremlin Master
Extensions available
Community Hero

Re: how to get date value equal to today's date without timestamp from the Date column in a grid.


@msap wrote:

how do you define rowIndex here?

Is it find row method, if I use Find row : value 6/14/2018 was not found in the created date column is seen 


Notice that @tristaanogre's example says "for all the rows in the grid".  You are looping through the grid and checking each one to see if the date matches today.  There is no magic shortcut for finding a certain date value (or any other value).  You look at a row and either it matches or it doesn't.

Frequent Contributor

Re: how to get date value equal to today's date without timestamp from the Date column in a grid.

Thanksalot Martin! I changed the rowIndex to the value i which I used in for Loop.

It retrives only one record instead I have two records with same date, any other changes to it .

 

 

 

for(i=0;i<=Grid.wRowCount-1;i++)
{
var dateString = Grid.wValue(i, "Created Date");
if (aqString.Find(dateString, FormatStr, 0, false) != -1) {
Log.Message(FormatStr + "FormatStr" + "' was found in string '" + "dateString")
//var foundRow = i;
break;
}
else Log.Message(" no date found")
}
}

Community Hero

Re: how to get date value equal to today's date without timestamp from the Date column in a grid.

If you want it to find and log all dates, simply remove the "break" line.


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.

Mysterious Gremlin Master
Extensions available
New Here?
Join us and watch the welcome video:
Top Kudoed Authors