Krishna Logo
qa training in canada now
Divied
Call: Anusha @ 1 (877) 864-8462

 

Latest News
Home Navigation Divied
OTHERS Navigation Divied QUICK TEST PROFESSIONAL Navigation Divied How to format a date to dd/mon/yyyy
How To Format A Date To Dd/mon/yyyy
How to format a date to dd/mon/yyyy

How to format a date to dd/mon/yyyy

The user would like to retrieve the system date in a specific format (such as DD/MON/YYYY). Is there a way to specify the desired format?
________________________________________
Solution: Retrieving the date in the desired format
QuickTest Professional does not have a built-in function that will allow you to specify the format of the returned date. You can write custom functions to get the date in the desired format. VBScript's date and time functions can be used internally.
Date
Returns the current system date.
Day(date)
Returns a whole number between 1 and 31, inclusive, representing the day of the month.
Month(date)
Returns a whole number between 1 and 12, inclusive, representing the month of the year.
Year(date)
Returns a whole number representing the year.
MonthName(month[, abbreviate])
Returns a string indicating the specified month.
WeekdayName(weekday, abbreviate, firstdayofweek)
Returns a string indicating the specified day of the week.
date    Any expression that represents a date.
month    The numeric designation of the month.
weekday    The numeric designation for the day of the week.
abbreviate    Boolean value that indicates if the month or weekday name is to be abbreviated.
For additional information on these functions or the time functions, refer to the VBScript Reference Guide (QuickTest Professional Help -> Microsoft Windows Script Technologies -> VBScript -> Reference -> Functions).
Note:
This function is not part of QuickTest Professional. It is not guaranteed to work and is not supported by Mercury Customer Support. You are responsible for any and all modifications that may be required.
Example:
Function date_ddmonyyyy()
' return the date in the DD/MON/YYYY format, ex. 31/Aug/2004
a = MonthName(Month(Date()), true)
b = Day(Date())
c = Year(Date())
If b<10 Then
b="0"& b
End If
date_ddmonyyyy = b & "/" & a & "/" & c
End Function
d = date_ddmonyyyy()
msgbox d


Shadow Bottom
 
 
© 2005 -