Knowledge Day
How to use the
TIMESTAMPADD
parameter to
retrieve by today - X
time in an Alma
Analytics report
Yoel Kortick | Sept. 2024 1
Agenda • Introduction
• Applying the TIMESTAMPADD filter on event date
• Applying the TIMESTAMPADD filter on loan due date
2
Introduction
3
Introduction
• There may be cases where the library is creating a report and does
not want to "hard code" a date.
• For example, the library may not want to know which items arrived
from Sept. 06 – 12, but instead want to know which items arrived in
the last week.
• Similarly, the library may wish to know how many loans were made by
users of group "Undergraduate" in the past year.
4
Introduction
• By using a variable which controls the date the report is "dynamic" in
that any time it is opened it automatically retrieves by the current
date minus a certain number of days, weeks, months or years.
• The variable is called TIMESTAMPADD
• Thus, weekly reports may be called, for example, "Number of … in the
last week"
5
Applying the
TIMESTAMPADD filter on
event date
6
Applying the TIMESTAMPADD filter on event date
• Here is the criteria tab of a report of successful logins after or on Jan. 1,
2023. It is created in the "System Events" subject area
7
Applying the TIMESTAMPADD filter on event date
• Here are the results
8
Applying the TIMESTAMPADD filter on event date
• We will now make the report always bring the last three weeks.
• Create any filter on the Event Date
9
Applying the TIMESTAMPADD filter on event date
• Select "Convert to SQL" and click OK
10
Applying the TIMESTAMPADD filter on event date
• Now we see that we have:
"Event Date"."Event Date" =
• We need to change this to reflect the kind of date retrieval we want
11
Applying the TIMESTAMPADD filter on event date
• If we want all event dates in the last 14 days: • This syntax can be used for all
"Event Date"."Event Date" >= TIMESTAMPADD(SQL_TSI_DAY, -14, CURRENT_DATE) date fields.
• The user needs to only change
the time units as needed.
• If we want all event dates in the last 2 years:
"Event Date"."Event Date" >= TIMESTAMPADD(SQL_TSI_YEAR, -2, CURRENT_DATE)
• If we want all event dates in the last 3 months:
"Event Date"."Event Date" >= TIMESTAMPADD(SQL_TSI_MONTH, -3, CURRENT_DATE)
• If we want all event dates in the last 1 week:
"Event Date"."Event Date" >= TIMESTAMPADD(SQL_TSI_WEEK, -1, CURRENT_DATE)
• If we want all event dates between today and 1 month from
now:
"Event Date"."Event Date" BETWEEN (CURRENT_DATE) AND TIMESTAMPADD(SQL_TSI_MONTH, +1,
CURRENT_DATE)
12
Applying the TIMESTAMPADD filter on event date
• For example, here we will get all event dates in the past three weeks:
"Event Date"."Event Date" >= TIMESTAMPADD(SQL_TSI_WEEK, -3,
CURRENT_DATE)
13
Applying the TIMESTAMPADD filter on event date
• The filter has been added to the report
14
Applying the TIMESTAMPADD filter on event date
• And now the report gives only the last three weeks (today is Sept. 04,
2024)
It goes as far back as
three weeks ago
15
Applying the
TIMESTAMPADD filter on
loan due date
16
Applying the TIMESTAMPADD filter on loan due date
• We will now create a report which retrieve all overdue items with a due
date between three months ago and 1 day ago.
• The TIMESTAMPADD retrieval for "less than one day ago" for the due
date is:
"Due Date"."Due Date" <= TIMESTAMPADD(SQL_TSI_DAY, -1,
CURRENT_DATE)
• The TIMESTAMPADD retrieval for "greater than three months ago" for
the due date is:
"Due Date"."Due Date" >= TIMESTAMPADD(SQL_TSI_MONTH, -3,
CURRENT_DATE)
17
Applying the TIMESTAMPADD filter on loan due date
• The TIMESTAMPADD retrieval for "between three months ago and one
day ago" for the due date is:
"Due Date"."Due Date" BETWEEN TIMESTAMPADD(SQL_TSI_MONTH, -
3, CURRENT_DATE) AND TIMESTAMPADD(SQL_TSI_DAY, -1,
CURRENT_DATE)
When using BETWEEN:
The oldest date (in this case three months ago) should appear before the
more recent date (in this case one day ago)
18
Applying the TIMESTAMPADD filter on loan due date
• Here we have a report of all active loans and the due date
19
Applying the TIMESTAMPADD filter on loan due date
• The output has all loans regardless of due date because currently there
is not a filter on the due date
20
Applying the TIMESTAMPADD filter on loan due date
• In order to use the TIMESTAMPADD add we will do "Filter > Convert to
SQL" on the "Due Date"."Due Date"
21
Applying the TIMESTAMPADD filter on loan due date
• In order to use the TIMESTAMPADD add we will do "Filter > Convert to
SQL" on the "Due Date"."Due Date"
22
Applying the TIMESTAMPADD filter on loan due date
• We have the following, and will change it to
"Due Date"."Due Date" BETWEEN TIMESTAMPADD(SQL_TSI_MONTH, -
3, CURRENT_DATE) AND TIMESTAMPADD(SQL_TSI_DAY, -1,
CURRENT_DATE)
23
Applying the TIMESTAMPADD filter on loan due date
• Here is the new filter
24
Applying the TIMESTAMPADD filter on loan due date
• Here is the new filter
25
Applying the TIMESTAMPADD filter on loan due date
• Now we have due dates between three months ago and one day ago (if
such dues dates exist).
26
Knowledge Day
Thank
You.
Yoel Kortick
© 2024 Clarivate
Clarivate and its logo, as well as all other
trademarks used herein are trademarks of
their respective owners and used under
license.