How to add datetime to an input at playback

Class library usage, coding and language questions.
Gav
Posts: 27
Joined: Thu Oct 20, 2011 10:52 am

How to add datetime to an input at playback

Post by Gav » Fri Oct 21, 2011 2:48 pm

Hi,

I have an input field that I want to type "cheese" into. Is there a way I could add the current datetime so that when the recording plays back it inputs "cheese20111021-14:46:23"? I imagine it'll have something to do with variables, but I'm not sure how to go about doing that.

Thanks,

Gav

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: How to add datetime to an input at playback

Post by Ciege » Fri Oct 21, 2011 3:49 pm

Are you using the Recorder or your own code?
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...

Gav
Posts: 27
Joined: Thu Oct 20, 2011 10:52 am

Re: How to add datetime to an input at playback

Post by Gav » Fri Oct 21, 2011 4:47 pm

Hi Ciege,

It doesn't really matter how the step gets into the recording (sometimes I record, sometimes I add manually if the edit box is already in the repo). All I need it to do is append something to the end of my original input. I'm ideally wanting something unique, so datetime, or seconds/milliseconds.

Gav

User avatar
Ciege
Ranorex Guru
Posts: 1335
Joined: Thu Oct 16, 2008 6:46 pm
Location: Arizona, USA

Re: How to add datetime to an input at playback

Post by Ciege » Fri Oct 21, 2011 5:11 pm

OK, well then you can add code similar to this:

Code: Select all

strYear = System.DateTime.Now.Year.ToString();
strMonth = System.DateTime.Now.ToString("MM");
strDay = System.DateTime.Now.ToString("dd");
strHour = System.DateTime.Now.ToString("hh");
strMinute = System.DateTime.Now.ToString("mm");
strSecond = System.DateTime.Now.ToString("ss");

strDateTimeStamp = strYear + "_" + strMonth + "_" + strDay + "___" + strHour + "_" + strMinute + "_" + strSecond;
Then your input variable would be:

Code: Select all

"Cheese" + strDateTimeStamp;
If this or any response has helped you, please reply to the thread stating that it worked so other people with a similar issue will know how you fixed your issue!

Ciege...