Report generated 11-04-2023 10:42

Feature: SDATE Function

SDATE (Shift Date) function computes and returns relative a date or datetime in the future or past. You can use this feature to calculate expiration dates, maturity dates, contract dates, and other due dates.
Use a positive value to get a datetime in the future, and a negative value for datetimes in the past.

Here are the keyword arguments

- years, months, weeks, days, hours, minutes, seconds, microseconds:  
    The integer value to specify may be negative or positive;  
- weekday:   
    This argument allows to shift a date to the specified next or previous Nth weekday.  
      
    This argument should be one of the weekday instances (SU, MO, TU, WE, TH, FR, SA). These instances may receive a parameter N, specifying the Nth weekday, which could be positive or negative  
    (like MO(+1) or MO(-2)). Not specifying it is the same as specifying +1. If the calculated date is already Monday, using MO(1) or MO(-1) won't change the day.  

The above arguments are applied in the following order:

years  
months  
days  
hours  
minutes  
seconds  
microseconds  
weekday  

Notice:

The EDATE and EOMONTH functions are only very special cases of this much more general SDATE function.

Scenarios

Given the date {start date}

When relative delta {relative delta} is applied

Then the relative date should be {relative date}

Examples:

descriptionstart daterelative deltarelative date
next month2021-09-20months=+12021-10-20
last month2021-09-20months=-12021-08-20
next two months2021-09-20months=+22021-11-20
next month, plus one week2021-09-20months=+1, weeks=+12021-10-27
one month before one year2021-09-20years=+1, months=-12022-08-20
one month after one year2021-09-20years=+1, months=+12022-10-20
next ten days2021-09-20days=+102021-09-30
next twelve days2021-09-20days=+122021-10-02
next friday2021-09-20weekday=FR2021-09-24
last friday in this month2021-09-20weekday=FR(-1)2021-09-17
next monday(it’s today!)2021-09-20weekday=MO2021-09-20
next monday, but not today2021-09-20days=+1, weekday=MO2021-09-27
first saturday in next month2021-09-20months=+1, weekday=SA2021-10-23

That maintain the last day of month when a day is 31. That also respect leap years.

Given the date {start date}

When relative delta {relative delta} is applied

Then the relative date should be {relative date}

Examples:

descriptionstart daterelative deltarelative date
next month2021-01-31months=+12021-02-28
last month2021-01-31months=-12020-12-31
next two months2021-01-31months=+22021-03-31
next three months2021-01-31months=+32021-04-30
next month, plus one week2021-01-31months=+1, weeks=+12021-03-07
one month before one year2021-01-31years=+1, months=-12021-12-31
one month after one year2021-01-31years=+1, months=+12022-02-28
one month after three year (2024 leap year!)2021-01-31years=+3, months=+12024-02-29
next ten days2021-01-31days=+102021-02-10
next friday2021-01-31weekday=FR2021-02-05
last friday in this month2021-01-31weekday=FR(-1)2021-01-29

That not maintain an end of month when the day value is less than 31.

Given the date {start date}

When relative delta {relative delta} is applied

Then the relative date should be {relative date}

Examples:

descriptionstart daterelative deltarelative date
next month2021-02-28months=+12021-03-28
last month2021-02-28months=-12021-01-28
next two months2021-02-28months=+22021-04-28
next three months2021-02-28months=+32021-05-28
next year2021-02-28years=+12022-02-28
next three year (2024 leap year!)2021-02-28years=+32024-02-28

Adding month(s) will never cross the month boundary.

Given the date {start date}

When relative delta {relative delta} is applied

Then the relative date should be {relative date}

Examples:

descriptionstart daterelative deltarelative date
next month2021-01-27months=+12021-02-27
next month2021-01-28months=+12021-02-28
next month2021-01-29months=+12021-02-28
next month2021-01-30months=+12021-02-28
next month2021-01-31months=+12021-02-28
next two months2021-01-31months=+22021-03-31
next three months2021-01-31months=+32021-04-30

Given the date {start date}

When relative delta {relative delta} is applied

Then the relative date should be {relative date}

Examples:

descriptionstart daterelative deltarelative date
next hour2021-10-20T16:10:59hours=+12021-10-20T17:10:59
last hour2021-10-20T16:10:59hours=-12021-10-20T15:10:59
next ten hours2021-10-20T16:10:59hours=+102021-10-21T02:10:59
next 24 hours2021-10-20T16:10:59hours=+242021-10-21T16:10:59
next hour and ten minutes2021-10-20T16:10:59hours=+1, minutes=+102021-10-20T17:20:59
next 60 minutes2021-10-20T16:10:59minutes=+602021-10-20T17:10:59
next second2021-10-20T16:10:59seconds=+12021-10-20T16:11:00
next day, plus one hour2021-10-20T16:10:59days=+1, hours=+12021-10-21T17:10:59
one day after one month, plus one hour2021-10-20T16:10:59months=+1, days=+1, hours=+12021-11-21T17:10:59
one day after one month, plus one hour2021-01-31T16:10:59months=+1, days=+1, hours=+12021-03-01T17:10:59

Feature Coverage By Scenario

Test Outcomes

Test Performance

Key Statistics

Number of Scenarios 5 Total Duration 1s
Total Number of Test Cases 47 Fastest Test 14ms
Number of Manual Test Cases 0 Slowest Test 40ms
Tests Started Apr 11, 2023 10:42:08 Average Execution Time 20ms
Tests Finished Apr 11, 2023 10:42:09 Total Execution Time 1s

Automated Tests

feature Scenario Context Steps Started Total Duration Result
SDATE Function 1: The start date do not involve last day of month
description=next month, start date=2021-09-20, relative delta=months=+1, relative date=2021-10-20
windows 3 10:42:08 018ms SUCCESS
SDATE Function 2: The start date do not involve last day of month
description=last month, start date=2021-09-20, relative delta=months=-1, relative date=2021-08-20
windows 3 10:42:08 022ms SUCCESS
SDATE Function 3: The start date do not involve last day of month
description=next two months, start date=2021-09-20, relative delta=months=+2, relative date=2021-11-20
windows 3 10:42:08 029ms SUCCESS
SDATE Function 4: The start date do not involve last day of month
description=next month, plus one week, start date=2021-09-20, relative delta=months=+1, weeks=+1, relative date=2021-10-27
windows 3 10:42:08 030ms SUCCESS
SDATE Function 5: The start date do not involve last day of month
description=one month before one year, start date=2021-09-20, relative delta=years=+1, months=-1, relative date=2022-08-20
windows 3 10:42:08 026ms SUCCESS
SDATE Function 6: The start date do not involve last day of month
description=one month after one year, start date=2021-09-20, relative delta=years=+1, months=+1, relative date=2022-10-20
windows 3 10:42:08 031ms SUCCESS
SDATE Function 7: The start date do not involve last day of month
description=next ten days, start date=2021-09-20, relative delta=days=+10, relative date=2021-09-30
windows 3 10:42:08 020ms SUCCESS
SDATE Function 8: The start date do not involve last day of month
description=next twelve days, start date=2021-09-20, relative delta=days=+12, relative date=2021-10-02
windows 3 10:42:08 032ms SUCCESS
SDATE Function 9: The start date do not involve last day of month
description=next friday, start date=2021-09-20, relative delta=weekday=FR, relative date=2021-09-24
windows 3 10:42:08 039ms SUCCESS
SDATE Function 10: The start date do not involve last day of month
description=last friday in this month, start date=2021-09-20, relative delta=weekday=FR(-1), relative date=2021-09-17
windows 3 10:42:08 024ms SUCCESS
SDATE Function 11: The start date do not involve last day of month
description=next monday(it’s today!), start date=2021-09-20, relative delta=weekday=MO, relative date=2021-09-20
windows 3 10:42:08 016ms SUCCESS
SDATE Function 12: The start date do not involve last day of month
description=next monday, but not today, start date=2021-09-20, relative delta=days=+1, weekday=MO, relative date=2021-09-27
windows 3 10:42:08 020ms SUCCESS
SDATE Function 13: The start date do not involve last day of month
description=first saturday in next month, start date=2021-09-20, relative delta=months=+1, weekday=SA, relative date=2021-10-23
windows 3 10:42:08 014ms SUCCESS
SDATE Function 1: The start date with 31 as last day
description=next month, start date=2021-01-31, relative delta=months=+1, relative date=2021-02-28
windows 3 10:42:08 014ms SUCCESS
SDATE Function 2: The start date with 31 as last day
description=last month, start date=2021-01-31, relative delta=months=-1, relative date=2020-12-31
windows 3 10:42:08 016ms SUCCESS
SDATE Function 3: The start date with 31 as last day
description=next two months, start date=2021-01-31, relative delta=months=+2, relative date=2021-03-31
windows 3 10:42:08 015ms SUCCESS
SDATE Function 4: The start date with 31 as last day
description=next three months, start date=2021-01-31, relative delta=months=+3, relative date=2021-04-30
windows 3 10:42:08 015ms SUCCESS
SDATE Function 5: The start date with 31 as last day
description=next month, plus one week, start date=2021-01-31, relative delta=months=+1, weeks=+1, relative date=2021-03-07
windows 3 10:42:08 017ms SUCCESS
SDATE Function 6: The start date with 31 as last day
description=one month before one year, start date=2021-01-31, relative delta=years=+1, months=-1, relative date=2021-12-31
windows 3 10:42:08 018ms SUCCESS
SDATE Function 7: The start date with 31 as last day
description=one month after one year, start date=2021-01-31, relative delta=years=+1, months=+1, relative date=2022-02-28
windows 3 10:42:08 017ms SUCCESS
SDATE Function 8: The start date with 31 as last day
description=one month after three year (2024 leap year!), start date=2021-01-31, relative delta=years=+3, months=+1, relative date=2024-02-29
windows 3 10:42:08 016ms SUCCESS
SDATE Function 9: The start date with 31 as last day
description=next ten days, start date=2021-01-31, relative delta=days=+10, relative date=2021-02-10
windows 3 10:42:08 016ms SUCCESS
SDATE Function 10: The start date with 31 as last day
description=next friday, start date=2021-01-31, relative delta=weekday=FR, relative date=2021-02-05
windows 3 10:42:08 015ms SUCCESS
SDATE Function 11: The start date with 31 as last day
description=last friday in this month, start date=2021-01-31, relative delta=weekday=FR(-1), relative date=2021-01-29
windows 3 10:42:08 016ms SUCCESS
SDATE Function 1: The start date involve last day of february
description=next month, start date=2021-02-28, relative delta=months=+1, relative date=2021-03-28
windows 3 10:42:08 016ms SUCCESS
SDATE Function 2: The start date involve last day of february
description=last month, start date=2021-02-28, relative delta=months=-1, relative date=2021-01-28
windows 3 10:42:08 015ms SUCCESS
SDATE Function 3: The start date involve last day of february
description=next two months, start date=2021-02-28, relative delta=months=+2, relative date=2021-04-28
windows 3 10:42:08 018ms SUCCESS
SDATE Function 4: The start date involve last day of february
description=next three months, start date=2021-02-28, relative delta=months=+3, relative date=2021-05-28
windows 3 10:42:08 021ms SUCCESS
SDATE Function 5: The start date involve last day of february
description=next year, start date=2021-02-28, relative delta=years=+1, relative date=2022-02-28
windows 3 10:42:08 028ms SUCCESS
SDATE Function 6: The start date involve last day of february
description=next three year (2024 leap year!), start date=2021-02-28, relative delta=years=+3, relative date=2024-02-28
windows 3 10:42:08 016ms SUCCESS
SDATE Function 1: The months with different numbers of days
description=next month, start date=2021-01-27, relative delta=months=+1, relative date=2021-02-27
windows 3 10:42:08 017ms SUCCESS
SDATE Function 2: The months with different numbers of days
description=next month, start date=2021-01-28, relative delta=months=+1, relative date=2021-02-28
windows 3 10:42:09 017ms SUCCESS
SDATE Function 3: The months with different numbers of days
description=next month, start date=2021-01-29, relative delta=months=+1, relative date=2021-02-28
windows 3 10:42:09 017ms SUCCESS
SDATE Function 4: The months with different numbers of days
description=next month, start date=2021-01-30, relative delta=months=+1, relative date=2021-02-28
windows 3 10:42:09 016ms SUCCESS
SDATE Function 5: The months with different numbers of days
description=next month, start date=2021-01-31, relative delta=months=+1, relative date=2021-02-28
windows 3 10:42:09 016ms SUCCESS
SDATE Function 6: The months with different numbers of days
description=next two months, start date=2021-01-31, relative delta=months=+2, relative date=2021-03-31
windows 3 10:42:09 017ms SUCCESS
SDATE Function 7: The months with different numbers of days
description=next three months, start date=2021-01-31, relative delta=months=+3, relative date=2021-04-30
windows 3 10:42:09 017ms SUCCESS
SDATE Function 1: The time addition
description=next hour, start date=2021-10-20T16:10:59, relative delta=hours=+1, relative date=2021-10-20T17:10:59
windows 3 10:42:09 018ms SUCCESS
SDATE Function 2: The time addition
description=last hour, start date=2021-10-20T16:10:59, relative delta=hours=-1, relative date=2021-10-20T15:10:59
windows 3 10:42:09 040ms SUCCESS
SDATE Function 3: The time addition
description=next ten hours, start date=2021-10-20T16:10:59, relative delta=hours=+10, relative date=2021-10-21T02:10:59
windows 3 10:42:09 029ms SUCCESS
SDATE Function 4: The time addition
description=next 24 hours, start date=2021-10-20T16:10:59, relative delta=hours=+24, relative date=2021-10-21T16:10:59
windows 3 10:42:09 033ms SUCCESS
SDATE Function 5: The time addition
description=next hour and ten minutes, start date=2021-10-20T16:10:59, relative delta=hours=+1, minutes=+10, relative date=2021-10-20T17:20:59
windows 3 10:42:09 035ms SUCCESS
SDATE Function 6: The time addition
description=next 60 minutes, start date=2021-10-20T16:10:59, relative delta=minutes=+60, relative date=2021-10-20T17:10:59
windows 3 10:42:09 024ms SUCCESS
SDATE Function 7: The time addition
description=next second, start date=2021-10-20T16:10:59, relative delta=seconds=+1, relative date=2021-10-20T16:11:00
windows 3 10:42:09 021ms SUCCESS
SDATE Function 8: The time addition
description=next day, plus one hour, start date=2021-10-20T16:10:59, relative delta=days=+1, hours=+1, relative date=2021-10-21T17:10:59
windows 3 10:42:09 022ms SUCCESS
SDATE Function 9: The time addition
description=one day after one month, plus one hour, start date=2021-10-20T16:10:59, relative delta=months=+1, days=+1, hours=+1, relative date=2021-11-21T17:10:59
windows 3 10:42:09 015ms SUCCESS
SDATE Function 10: The time addition
description=one day after one month, plus one hour, start date=2021-01-31T16:10:59, relative delta=months=+1, days=+1, hours=+1, relative date=2021-03-01T17:10:59
windows 3 10:42:09 017ms SUCCESS

Manual Tests

No manual tests were recorded
Serenity BDD version 3.6.22