using a Timestamp or Date as a variable

Ask general questions here.
nico
Posts: 24
Joined: Tue Nov 04, 2014 3:13 pm

using a Timestamp or Date as a variable

Post by nico » Fri Mar 27, 2015 8:39 am

Is there a way to use a Timestamp or Date as a variable?

I can't figure out a way how to do it

CookieMonster
Certified Professional
Certified Professional
Posts: 74
Joined: Mon Aug 14, 2006 7:17 pm
Location: CH

Re: using a Timestamp or Date as a variable

Post by CookieMonster » Fri Mar 27, 2015 9:06 am

Hi Nico,

Just on the "fly" it's not possible to get time stamp or date into a variable. But there are multiple ways to get them into a variable.

One of the solution is to create a UserCodemodule with a variable in it. But there is a small disadvantage, on UserCodeModule you can not pass any parameter, for e.g. if you want to pass the format of the time stamp. This has to be done directly in the Module.

Code: Select all

varTimeDateStamp = System.DateTime.Now.ToString("yy.MMM.dd_HHmmss");
And then you link this variable to the other modules.

The other solution is, that you have a recoding module, with a User Code Function with a string parameter, and there you can pass the format, when you call the function from the recording module.
Define a variable in the recording module like varTimeStamp.
Recording Module

Code: Select all

UserCode | GetTimeStamp | yy.MM.dd |

Code: Select all

private void GetTimeStamp(string format)
{
  varTimeStamp = System.DateTime.Now.ToString(forrmat);
}
And then the only thing you have to is, to link the variable to the other modules.

Cheers
Dan

nico
Posts: 24
Joined: Tue Nov 04, 2014 3:13 pm

Re: using a Timestamp or Date as a variable

Post by nico » Fri Mar 27, 2015 9:13 am

Thanks Dan!

Seems like a good solution.