Skip to content

Commit

Permalink
Monthly Normalization Toolkit Experimental API Docs (github#1469)
Browse files Browse the repository at this point in the history
* adding docs for monthly normalization toolkit experimental functions

Co-authored-by: Lana Brindley <[email protected]>
  • Loading branch information
thatzopoulos and Loquacity authored Aug 22, 2022
1 parent 74cd940 commit 3b0f848
Show file tree
Hide file tree
Showing 2 changed files with 74 additions and 0 deletions.
36 changes: 36 additions & 0 deletions api/days_in_month.md
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
```
38 changes: 38 additions & 0 deletions api/month_normalize.md
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
```

0 comments on commit 3b0f848

Please sign in to comment.