forked from github/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Monthly Normalization Toolkit Experimental API Docs (github#1469)
* adding docs for monthly normalization toolkit experimental functions Co-authored-by: Lana Brindley <[email protected]>
- Loading branch information
1 parent
74cd940
commit 3b0f848
Showing
2 changed files
with
74 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
api_name: days_in_month() | ||
excerpt: Calculates days in month given a timestamptz | ||
license: community | ||
toolkit: true | ||
api_experimental: true | ||
topic: hyperfunctions | ||
tags: [normalization, hyperfunctions] | ||
api_category: hyperfunctions | ||
hyperfunction_toolkit: true | ||
--- | ||
## days_in_month() | ||
|
||
Given a timestamptz, returns how many days are in that month. | ||
|
||
### Required arguments | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|`date`|`TIMESTAMPTZ`|Timestamp to use to calculate how many days in the month| | ||
|
||
### Sample usage | ||
|
||
Calculate how many days in the month of January 1, 2022: | ||
|
||
```sql | ||
SELECT toolkit_experimental.days_in_month('2021-01-01 00:00:00+03'::timestamptz) | ||
``` | ||
|
||
The output looks like this: | ||
|
||
``` | ||
days_in_month | ||
---------------------- | ||
31 | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
api_name: month_normalize() | ||
excerpt: Normalization metric based on reference date and days | ||
license: community | ||
toolkit: true | ||
api_experimental: true | ||
topic: hyperfunctions | ||
tags: [normalization, hyperfunctions] | ||
api_category: hyperfunctions | ||
hyperfunction_toolkit: true | ||
--- | ||
## month_normalize() | ||
|
||
Normalize the provided metric based on reference date and days. | ||
|
||
### Required arguments | ||
|
||
|Name|Type|Description| | ||
|-|-|-| | ||
|`metric`|`float8`|| | ||
|`reference_date`|`TIMESTAMPTZ`|Timestamp to normalize the metric with| | ||
|`days`|`float8`|Optional, defaults to 365.25/12 if none provided| | ||
|
||
### Sample usage | ||
|
||
Get the normalized value for a metric of 1000, and a reference date of January 1, 2021: | ||
|
||
```sql | ||
SELECT toolkit_experimental.month_normalize(1000,'2021-01-01 00:00:00+03'::timestamptz | ||
``` | ||
|
||
The output looks like this: | ||
|
||
``` | ||
month_normalize | ||
---------------------- | ||
981.8548387096774 | ||
``` |