[e988c2]: / docs / includes / generated_docs / language__date_arithmetic.md

Download this file

498 lines (422 with data), 15.7 kB


class DateDifference(lhs, rhs)

Represents the difference between two dates or date series (i.e. it is what you
get when you perform subtractions on DatePatientSeries
or DateEventSeries).

days 🔗

The value of the date difference in days (can be positive or negative).

weeks 🔗

The value of the date difference in whole weeks (can be positive or negative).

months 🔗

The value of the date difference in whole calendar months (can be positive or
negative).

years 🔗

The value of the date difference in whole calendar years (can be positive or
negative).


class days(value)

Represents a duration of time specified in days.

Example usage:

last_medication_date = medications.sort_by(medications.date).last_for_patient().date
start_date = last_medication_date - days(90)
end_date = last_medication_date + days(90)
self == other 🔗

Return True if other has the same value and units, and False otherwise.

Hence, the result of weeks(1) == days(7) will be False.

self != other 🔗

Return the inverse of == above.

self + other 🔗

If other is a date or date series, add this duration to other
to produce a new date.

If other is another duration with the same units, add the two durations
together to produce a new duration.

self - other 🔗

Subtract other from this duration. other must be a
duration in the same units.

- self 🔗

Invert this duration, i.e. count the duration backwards in time
if it was originally forwards, and vice versa.

starting_on(date) 🔗

Return a list of time intervals covering the duration starting on
date. Each interval lasts one unit.

Example usage:

weeks(3).starting_on("2000-01-01")

The above would return:

[
    (date(2000, 1, 1), date(2000, 1, 7)),
    (date(2000, 1, 8), date(2000, 1, 14)),
    (date(2000, 1, 15), date(2000, 1, 21)),
]

Useful for generating the intervals arguments to Measures.

ending_on(date) 🔗

Return a list of time intervals covering the duration ending on
date. Each interval lasts one unit.

Example usage:

weeks(3).ending_on("2000-01-21")

The above would return:

[
    (date(2000, 1, 1), date(2000, 1, 7)),
    (date(2000, 1, 8), date(2000, 1, 14)),
    (date(2000, 1, 15), date(2000, 1, 21)),
]

Useful for generating the intervals arguments to Measures.


class months(value)

Represents a duration of time specified in calendar months.

Example usage:

last_medication_date = medications.sort_by(medications.date).last_for_patient().date
start_date = last_medication_date - months(3)
end_date = last_medication_date + months(3)

Consider using days() or weeks() instead -
see the section on Ambiguous Dates for more.

self == other 🔗

Return True if other has the same value and units, and False otherwise.

Hence, the result of weeks(1) == days(7) will be False.

self != other 🔗

Return the inverse of == above.

self + other 🔗

If other is a date or date series, add this duration to other
to produce a new date.

If other is another duration with the same units, add the two durations
together to produce a new duration.

self - other 🔗

Subtract other from this duration. other must be a
duration in the same units.

- self 🔗

Invert this duration, i.e. count the duration backwards in time
if it was originally forwards, and vice versa.

starting_on(date) 🔗

Return a list of time intervals covering the duration starting on
date. Each interval lasts one unit.

Example usage:

weeks(3).starting_on("2000-01-01")

The above would return:

[
    (date(2000, 1, 1), date(2000, 1, 7)),
    (date(2000, 1, 8), date(2000, 1, 14)),
    (date(2000, 1, 15), date(2000, 1, 21)),
]

Useful for generating the intervals arguments to Measures.

ending_on(date) 🔗

Return a list of time intervals covering the duration ending on
date. Each interval lasts one unit.

Example usage:

weeks(3).ending_on("2000-01-21")

The above would return:

[
    (date(2000, 1, 1), date(2000, 1, 7)),
    (date(2000, 1, 8), date(2000, 1, 14)),
    (date(2000, 1, 15), date(2000, 1, 21)),
]

Useful for generating the intervals arguments to Measures.


class weeks(value)

Represents a duration of time specified in weeks.

Example usage:

last_medication_date = medications.sort_by(medications.date).last_for_patient().date
start_date = last_medication_date - weeks(12)
end_date = last_medication_date + weeks(12)
self == other 🔗

Return True if other has the same value and units, and False otherwise.

Hence, the result of weeks(1) == days(7) will be False.

self != other 🔗

Return the inverse of == above.

self + other 🔗

If other is a date or date series, add this duration to other
to produce a new date.

If other is another duration with the same units, add the two durations
together to produce a new duration.

self - other 🔗

Subtract other from this duration. other must be a
duration in the same units.

- self 🔗

Invert this duration, i.e. count the duration backwards in time
if it was originally forwards, and vice versa.

starting_on(date) 🔗

Return a list of time intervals covering the duration starting on
date. Each interval lasts one unit.

Example usage:

weeks(3).starting_on("2000-01-01")

The above would return:

[
    (date(2000, 1, 1), date(2000, 1, 7)),
    (date(2000, 1, 8), date(2000, 1, 14)),
    (date(2000, 1, 15), date(2000, 1, 21)),
]

Useful for generating the intervals arguments to Measures.

ending_on(date) 🔗

Return a list of time intervals covering the duration ending on
date. Each interval lasts one unit.

Example usage:

weeks(3).ending_on("2000-01-21")

The above would return:

[
    (date(2000, 1, 1), date(2000, 1, 7)),
    (date(2000, 1, 8), date(2000, 1, 14)),
    (date(2000, 1, 15), date(2000, 1, 21)),
]

Useful for generating the intervals arguments to Measures.


class years(value)

Represents a duration of time specified in calendar years.

Example usage:

last_medication_date = medications.sort_by(medications.date).last_for_patient().date
start_date = last_medication_date - years(1)
end_date = last_medication_date + years(1)

Consider using days() or weeks() instead -
see the section on Ambiguous Dates for more.

self == other 🔗

Return True if other has the same value and units, and False otherwise.

Hence, the result of weeks(1) == days(7) will be False.

self != other 🔗

Return the inverse of == above.

self + other 🔗

If other is a date or date series, add this duration to other
to produce a new date.

If other is another duration with the same units, add the two durations
together to produce a new duration.

self - other 🔗

Subtract other from this duration. other must be a
duration in the same units.

- self 🔗

Invert this duration, i.e. count the duration backwards in time
if it was originally forwards, and vice versa.

starting_on(date) 🔗

Return a list of time intervals covering the duration starting on
date. Each interval lasts one unit.

Example usage:

weeks(3).starting_on("2000-01-01")

The above would return:

[
    (date(2000, 1, 1), date(2000, 1, 7)),
    (date(2000, 1, 8), date(2000, 1, 14)),
    (date(2000, 1, 15), date(2000, 1, 21)),
]

Useful for generating the intervals arguments to Measures.

ending_on(date) 🔗

Return a list of time intervals covering the duration ending on
date. Each interval lasts one unit.

Example usage:

weeks(3).ending_on("2000-01-21")

The above would return:

[
    (date(2000, 1, 1), date(2000, 1, 7)),
    (date(2000, 1, 8), date(2000, 1, 14)),
    (date(2000, 1, 15), date(2000, 1, 21)),
]

Useful for generating the intervals arguments to Measures.