Web Functional Testing > Function Reference > Adding Date Functions

Adding Date Functions

Tags:  

Description : Date Functions are utility functions used to do date / time related actions inside the scripts.

Where the Date Functions can be used ?

Following is the scenario where Date Functions can be used,
  • The date functions can be used where to input date values in the web application
How to insert date functions in the script ?
  • Click the "Insert Built-in Function" link available above the script editor
  • In the "Built-in-Function" window, select the "Date Functions" in the "Category" combo.
  • Select the appropriate function to be used in the "Functions" combo.
  • Configure the values for function arguments and click on "Paste" button to add the function to the script.
Following are the various functions available in the Date Functions category,
  1. adjustDate
  2. adjustGivenDate
  3. getDateDiff
  4. getDateStr
  5. getDateTime
  6. getDateTimePart
  7. getDay
  8. getHour
  9. getNextDay
  10. getNextHour
  11. getPreviousDay
  12. getPreviousHour
  13. getTimeLong
  14. getTimeStr

adjustDate

 Function Description:

To retrieve the date value that is obtained by adding or subtracting the number of days (given in the Offset value) to the current date.

 How to Define:

result = adjustDate("Format", "Offset")

Format = MM/dd/yyyy or MM/dd/yy.

Offset = Integer value to add or subtract from the current date.

 Example:

result=adjustDate("MM/dd/yyyy","-3")

displayMessage(result)

 Return Value:

 String

 Top


adjustGivenDate

 Function Description:

 To retrieve the date value that is obtained by adding or subtracting the number of days (given in the offset value) to the given date.

 How to Define:

 result = adjustGivenDate("Indate", "Offset")

Indate = Specify a date in MM/dd/yyyy.

Offset = Integer value to add or subtract from the given date.

 Example:

result=adjustGivenDate("04/05/2006","2")

displayMessage(result)

 Return Value:

 String

 Top


getDateDiff

 Function Description:

 To get the difference between the given from date and to date.

 How to Define:

 result = getDateDiff(fromDate,toDate)

fromDate = Specify a from date in MM/DD/YYYY format.

toDate = Specify a to date in MM/DD/YYYY format.

 Example:

 result = getDateDiff("05/02/2006","05/04/2006")

displayMessage(result)

 Return Values:

 Integer


getDateStr

 Function Description:

 To retrieve the current date in string format.

 How to Define:

result = getDateStr()

No arguments

 Example:

result = getDateStr()

displayMessage(result)

 Return Value:

 String

 Top


getDateTime

 Function Description:

 To retrieve the current date and time in string formal.

 How to Define:

result = getDateTime()

No arguments

 Example:

result = getDateTime()

displayMessage(result)

 Return Value:

 String

 Top


getDateTimePart

 Function Description:

 To retrieve the desired part of the current date or time.

 How to Define:

 result = getDateTimePart("<DESIRED_PART_OF_DATE_OR_TIME>")

"<DESIRED_PART_OF_DATE_OR_TIME>" = YEAR, MONTH, DAY, DAY_OF_MONTH, DAY_OF_WEEK, HOUR, MINUTE, SECOND, MILLISECOND.

 Example:

result = getDateTimePart("YEAR")

displayMessage(result)

 Return Value:

 Integer

 Top


getDay

 Function Description:

 To retrieve the current week day.

 How to Define:

result = getDay()

No arguments

 Example:

result = getDay()

displayMessage(result)

 Return Value:

 String

 Top


getHour

 Function Description:

 To retrieve the current hour.

 How to Define:

result = getHour()

No arguments

 Example:

result = getHour()

displayMessage(result)

 Return Value:

 String

 Top


getNextDay

 Function Description:

 To retrieve the next week day from the current date.


 How to Define:

 result =getNextDay()

 Example:

result =getNextDay()

displayMessage(result)

 Return Value:

 String

 Top


getNextHour

 Function Description:

 To retrieve the next hour from the current time.

 How to Define:

 result =getNextHour()

 Example:

result =getNextHour()

displayMessage(result)

 Return Values:

 String

 Top


getPreviousDay

 Function Description: 

 To retrieve the previous week day from the current date.

 How to Define:

 result =getPreviousDay()

 Example:

result =getPreviousDay()

displayMessage(result)

 Return Values:

 String

 Top


getPreviousHour

 Function Description:

 To retrieve the previous hour from the current time.

 How to Define:

 result =getPreviousHour()

 Example:

result =getPreviousHour()

displayMessage(result)

Return Values:

 String

 Top


getTimeLong

 Function Description:

 To retrieve the current time in long format.

 How to Define:

 result =getTimeLong()

 Example:

result =getTimeLong()

displayMessage(result)

 Return Values:

 Long

Top


getTimeStr

 Function Description:

 To retrieve the current time in string format.

 How to Define:

 result =getTimeStr()

 Example:

result =getTimeStr)

displayMessage(result)

 Return Values:

 String

 Top


0 Comments  Show recent to old
Post a comment


 RSS of this page

Copyright © 2009, Zoho Corporation. All Rights Reserved.