Having problems with your account or logging in?
A lot of changes are happening in the community right now. Some may affect you. READ MORE HERE

How to format a DateTime data type in Silk Test Workbench .Net script

How to format a DateTime data type in Silk Test Workbench .Net script

- In order to format a DateTime data type in a Silk Test Workbench Visual Test you can use FormatDate().  This is an Expression Designer function that is available through a Visual Test. 

- To perform the same in a .net script you will be required to manually code this.  Please see example below that will format a Date to the format D-MMM-YYYY:-

 

Public Module Main
    Dim _desktop As Desktop = Agent.Desktop

    Public Sub Main()
        FormatCurrentDate()
    End Sub
                
    Public Sub FormatCurrentDate()
         'Set Variables
        Dim dateCurrentDate As DateTime
        Dim curdate As String = "d MMM yyyy"
                                
        'Get current system Date & time
        dateCurrentDate = Date.Now
                                
        'Format date and Print to TestResult
        Workbench.ResultComment(dateCurrentDate.ToString(curdate))

    End Sub
End Module

 

More examples of formatting DateTime data types can be retrieved from the link below:

http://msdn.microsoft.com/en-us/library/8kb3ddd4%28v=vs.110%29.aspx

DISCLAIMER:

Some content on Community Tips & Information pages is not officially supported by Micro Focus. Please refer to our Terms of Use for more detail.
Top Contributors
Version history
Revision #:
1 of 1
Last update:
‎2014-10-10 14:40
Updated by:
 
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.