Skip to content
TimescaleDB - Timeseries database for PostgreSQL
  • Timescale.com
  • Try for free
Get started
Use Timescale
Tutorials
Code quick starts
API Reference
Hypertables & chunks
Distributed hypertables
Compression
Continuous aggregates
Data retention
Actions and automation
Hyperfunctions
approximate_row_count
first
last
histogram
time_bucket
time_bucket_ng
days_in_month
month_normalize
Approximate count distinct
Saturating math
Statistical and regression analysis
Minimum and maximum
Financial analysis
Gapfilling
Percentile approximation
Counters and gauges
Time-weighted calculations
Downsampling
Frequency analysis
State tracking
Informational views
Configuration
Administration Functions
API Reference Tag Overview
Other deployment options
About Timescale
Find a docs page
TimescaleDB API referenceHyperfunctions

days_in_month()

ToolkitTimescaleDB Toolkit functions are available under Timescale Community Edition. They are automatically included with Timescale, but must be installed separately for self-hosted TimescaleDB. Click to learn more.

Given a timestamptz, returns how many days are in that month.

Required arguments

NameTypeDescription
dateTIMESTAMPTZTimestamp to use to calculate how many days in the month

Sample usage

Calculate how many days in the month of January 1, 2022:

SELECT days_in_month('2021-01-01 00:00:00+03'::timestamptz)

The output looks like this:

days_in_month
----------------------
31

Keywords

hyperfunctionsToolkitnormalization

Found an issue on this page?

Report an issue!
Previoustime_bucket_ngNextmonth_normalize

Related Content

month_normalize()
Normalize a monthly metric based on number of days in month
Hyperfunctions
Use hyperfunctions to simplify data analysis
Downsampling functions
API reference for the downsampling functions
Saturating math functions
API reference for the saturating math functions
state_agg()
API reference for the state_agg() functions
max_n()
API reference for the max_n() functions