Date-Related Functions
Function
Signature
Meaning
Availability
countryCode
String countryCode(String country)
Gets the ISO 3166 2-letter country code for the specified country code or English country name.
Codebeamer 7.8 and later
Date
Date Date(String date[, String timezone])
Creates a date according to the passed argument (and timezone).
Codebeamer 9.5 and later
isSameDay
boolean isSameDay(Date date1, Date date2)
Returns true if both dates are within the same calendar day. This is equivalent to inSamePeriod(date1, date2, day).
Codebeamer 9.3 and later
inSamePeriod
boolean inSamePeriod(Date date1, Date date2, String period)
Returns true if both dates are within the same calendar period, that is, Year, Month, Day and so on. For example, inSamePeriod(Date(2019-01-01 00:00), Date(2019-01-01 12:00, period) returns true for Y(ear), M(onth) and d (ay) and false for any other period.
Codebeamer 5.4 and later
roundDate
Date roundDate(Date date, String precision)
Rounds a date according to the specified precision.
Codebeamer 5.4 and later
shiftDate
Date shiftDate(Date date, int distance, String unit)
Shifts a date by the specified distance in the specified unit (see below). To shift by net working time, you must use scrollWorkTime (CB-9.3 and later) instead.
Codebeamer 5.4 and later
timeBetween
Long timeBetween(Date date1, Date date2, String unit)
Returns the time between two dates in the specified unit (see below), based on 7 days per week, 24 hours per day, 60 minutes per hour and 60 seconds per minute. To get the net working time between two dates, you must use workTimeBetween (CB-9.3 and later) instead. The result can be negative, if date1 is after date2. For example, timeBetween(Date(2018-12-31), Date(2019-01-01, Year) returns 0, because the difference between the two dates is less than a year. It's also less than a month or a week. But it is 1 d(ay(s)), 24 h(our(s)), 1440 m(in(ute(s))) or 86400 s(ec(ond(s))).
Codebeamer 9.3 and later
truncateDate
Date truncateDate(Date date, String precision)
Truncates a date according to the specified precision.
Codebeamer 5.4 and later
The date parameter for the Date function can be either an absolute date or string constants. You can specify the absolute date as yyyy-MM-dd[ HH:mm[:ss]]. Optionally, you can specify the times zone in the following way:
UTC if the literal represents coordinated universal time.
default, system, or local if the literal represents default, system, or local time of the Codebeamer installation/server.
As time zone offset from GMT as GMT[±][hh[:mm]].
As a time zone abbreviation.
If no timezone for the date is specified, the default is the time zone of the current user. If there is no current user or the user does not have a special time zone setting, the default time zone of the Codebeamer system.
The date parameter can be also specified with one of the following string constants:
Now
Today
Tomorrow
Yesterday
Start of this week
End of this week
Start of next week
End of next week
Start of last week
End of last week
Start of this month
End of this month
Start of next month
End of next month
Start of last month
End of last month
Start of this year
End of this year
Start of next year
End of next year
Start of last year
End of last year
Example:
endDate >= Date(today)
The precision for roundDate and truncateDate and the unit of shiftDate and timeBetween must be an abbreviation of:
Year
Month
Week
day
hour
minute
second
Example:
roundDate(endDate, h)
shiftDate(startDate, 30, min)
Was this helpful?