File tree 2 files changed +74
-0
lines changed
2 files changed +74
-0
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ api_name : days_in_month()
3
+ excerpt : Calculates days in month given a timestamptz
4
+ license : community
5
+ toolkit : true
6
+ api_experimental : true
7
+ topic : hyperfunctions
8
+ tags : [normalization, hyperfunctions]
9
+ api_category : hyperfunctions
10
+ hyperfunction_toolkit : true
11
+ ---
12
+ ## days_in_month()
13
+
14
+ Given a timestamptz, returns how many days are in that month.
15
+
16
+ ### Required arguments
17
+
18
+ | Name| Type| Description|
19
+ | -| -| -|
20
+ | ` date ` | ` TIMESTAMPTZ ` | Timestamp to use to calculate how many days in the month|
21
+
22
+ ### Sample usage
23
+
24
+ Calculate how many days in the month of January 1, 2022:
25
+
26
+ ``` sql
27
+ SELECT toolkit_experimental .days_in_month (' 2021-01-01 00:00:00+03' ::timestamptz )
28
+ ```
29
+
30
+ The output looks like this:
31
+
32
+ ```
33
+ days_in_month
34
+ ----------------------
35
+ 31
36
+ ```
Original file line number Diff line number Diff line change
1
+ ---
2
+ api_name : month_normalize()
3
+ excerpt : Normalization metric based on reference date and days
4
+ license : community
5
+ toolkit : true
6
+ api_experimental : true
7
+ topic : hyperfunctions
8
+ tags : [normalization, hyperfunctions]
9
+ api_category : hyperfunctions
10
+ hyperfunction_toolkit : true
11
+ ---
12
+ ## month_normalize()
13
+
14
+ Normalize the provided metric based on reference date and days.
15
+
16
+ ### Required arguments
17
+
18
+ | Name| Type| Description|
19
+ | -| -| -|
20
+ | ` metric ` | ` float8 ` ||
21
+ | ` reference_date ` | ` TIMESTAMPTZ ` | Timestamp to normalize the metric with|
22
+ | ` days ` | ` float8 ` | Optional, defaults to 365.25/12 if none provided|
23
+
24
+ ### Sample usage
25
+
26
+ Get the normalized value for a metric of 1000, and a reference date of January 1, 2021:
27
+
28
+ ``` sql
29
+ SELECT toolkit_experimental .month_normalize (1000 ,' 2021-01-01 00:00:00+03' ::timestamptz
30
+ ```
31
+
32
+ The output looks like this:
33
+
34
+ ```
35
+ month_normalize
36
+ ----------------------
37
+ 981.8548387096774
38
+ ```
You can’t perform that action at this time.
0 commit comments