Trying to get a current date to enter into a field
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2011
02:19 AM
10-28-2011
02:19 AM
Trying to get a current date to enter into a field
Here is the originally generated vb script:
Call SSCalendarMaskedEdit.Keys("03152011[Tab]")
And we are attempting to place a current date into the field minus a set number of days and all of our current attempts to seems to cause errors and I'm unsure what were putting in wrong. To clarify Current Date Minus say 15 days (Ex. 10/30/2011 - 15 days = 10/15/2011)
Here is one of our recent attempts: Giving the error - Object required: 'DateValue(...)'
Dim dtmTest
Dim formatedDate
Dim currentDate
Set currentDate = DateValue(Now)
Set dtmTest = DateAdd("D", -15, currentDate)
Set formatedDate = Format(dtmTest, "mmddyyyy")
Call SSCalendarMaskedEdit.Keys(formatedDate & "[Tab]")
The way we have achieved this in the past using a slightly different method was such:
(Format(DateAdd("D", -15, Now), "mmddyyyy") )
This would not work either.
Can anyone assist me with the proper terms that will work within TestComplete?
Also, the return for 3/1/2011 would need to be formatted like: 03012011
Thanks for the help
Call SSCalendarMaskedEdit.Keys("03152011[Tab]")
And we are attempting to place a current date into the field minus a set number of days and all of our current attempts to seems to cause errors and I'm unsure what were putting in wrong. To clarify Current Date Minus say 15 days (Ex. 10/30/2011 - 15 days = 10/15/2011)
Here is one of our recent attempts: Giving the error - Object required: 'DateValue(...)'
Dim dtmTest
Dim formatedDate
Dim currentDate
Set currentDate = DateValue(Now)
Set dtmTest = DateAdd("D", -15, currentDate)
Set formatedDate = Format(dtmTest, "mmddyyyy")
Call SSCalendarMaskedEdit.Keys(formatedDate & "[Tab]")
The way we have achieved this in the past using a slightly different method was such:
(Format(DateAdd("D", -15, Now), "mmddyyyy") )
This would not work either.
Can anyone assist me with the proper terms that will work within TestComplete?
Also, the return for 3/1/2011 would need to be formatted like: 03012011
Thanks for the help
4 REPLIES 4
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2011
02:59 AM
10-28-2011
02:59 AM
You'll want to use a combination of aqDateTime and aqConvert objects. So, the following function will write to the log today's date minus 5 days...
You'll need to adapt it for VBScript but this should demonstrate how to use those two object.
Relevant documentation:
http://smartbear.com/support/viewarticle/13474/ - aqDateTime.Now
http://smartbear.com/support/viewarticle/13488/ - aqDateTime.AddDays
http://smartbear.com/support/viewarticle/13451/ - aqConvert.DateTimeToFormatStr
Robert Martin
[Hall of Fame]
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
Vegas Thrill Rider
Extensions available
function tada()
{
var TodaysDate = aqDateTime.Now()
var FiveDaysAgo = aqDateTime.AddDays(TodaysDate, -5)
var FormattedDate = aqConvert.DateTimeToFormatStr(FiveDaysAgo, "%m%d%Y")
Log.Message(FormattedDate)
}
You'll need to adapt it for VBScript but this should demonstrate how to use those two object.
Relevant documentation:
http://smartbear.com/support/viewarticle/13474/ - aqDateTime.Now
http://smartbear.com/support/viewarticle/13488/ - aqDateTime.AddDays
http://smartbear.com/support/viewarticle/13451/ - aqConvert.DateTimeToFormatStr
Robert Martin
[Hall of Fame]
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
Vegas Thrill Rider
Extensions available
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2011
04:56 AM
10-28-2011
04:56 AM
Thanks for the help, I had stumbled upon the articles you mentioned just prior to you posting this.
This is the result that we got working:
Call SSCalendarMaskedEdit.Keys(aqConvert.DateTimeToFormatStr(aqDateTime.AddDays(aqDateTime.Now , -15), "%m%d%Y") & "[Tab]")
Thanks again.
This is the result that we got working:
Call SSCalendarMaskedEdit.Keys(aqConvert.DateTimeToFormatStr(aqDateTime.AddDays(aqDateTime.Now , -15), "%m%d%Y") & "[Tab]")
Thanks again.
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-30-2011
08:19 PM
10-30-2011
08:19 PM
Hi Jason,
While you've already got a working answer, I'd still like to explain the "Object required: 'DateValue(...)" error you got with your original code. It's caused by improper use of the Set keyword. In VBScript, you use Set only for object assignments. When a variable is assigned a simple value -- a string, number, date, etc. -- Set isn't needed:
Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
While you've already got a working answer, I'd still like to explain the "Object required: 'DateValue(...)" error you got with your original code. It's caused by improper use of the Set keyword. In VBScript, you use Set only for object assignments. When a variable is assigned a simple value -- a string, number, date, etc. -- Set isn't needed:
currentDate = DateValue(Now)
dtmTest = DateAdd("D", -15, currentDate)
Helen Kosova
SmartBear Documentation Team Lead
________________________
Did my reply answer your question? Give Kudos or Accept it as a Solution to help others. ⬇️⬇️⬇️
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2011
08:33 AM
11-01-2011
08:33 AM
Thanks for the assist, writing code isn't my primary background so sometimes I feel like I'm using a chainsaw for surgery but I'm learning and I read these forums quiet a bit for tips and tricks to pick up.
