NI TestStand

cancel
Showing results for 
Search instead for 
Did you mean: 

Use the SearchandReplace function to insert a specific date and time format as the replacement string

LabVIEW allows you to specify the format by using format codes for example

 

MMDDYY-00:00 would be specified like  %m%d%%y-%H:%M

 

I’m looking for an equivalent way to specify this in TestStand that I can use the SearchandReplace function to replace text in a template file with the format specified by the LabVIEW statement above.

0 Kudos
Message 1 of 4
(3,121 Views)

Hi RF_Dude_22,

 

Formatting date and time in TestStand is more manual than it is in LabVIEW. This example shows how you can generate a date string using the Date() function. The same idea can be applied using the Time() function to create a time string.

Steven Gloor
Staff Customer Engineer - CTA, CLD
Message 2 of 4
(3,069 Views)

What I have done is created a vi that creates the string I need in the format I need and assign it to a Local in TestStand, then I just read the contents of that Local using the SearchandReplace function. This works well, but was really hoping to be able to have TestStand creat the format I need, but have been unable to find a way. Yes, I can use the Date() and Time() functions to get the information I need, but then I still need to parse out the information I need, similar to the example you have pointed me at.

0 Kudos
Message 3 of 4
(3,063 Views)

Hi,

 

As Steven stated, you can use the Time() and Date() functions and format the returned values into the desired format using the following expression:

 

Locals.Date = Date(False,Locals.Year,Locals.Month,Locals.Day),
Locals.Time = Time(True,Locals.Hour,Locals.Minute,Locals.Second),

Locals.FormattedDateTime = Str(Locals.Month, "%02s") + Str(Locals.Day, "%02s") + Right(Str(Locals.Year),2) + "-" + Str(Locals.Hour, "%02s") + ":" + Str(Locals.Minute, "%02s")

 

Regards,

Charlie Rodway | Principal Software Engineer | Certified TestStand Architect (CTA)

Computer Controlled Solutions Ltd | NI Silver Alliance Partner | GDevCon#1 Sponsor

Message 4 of 4
(2,934 Views)