Skip to content
📣 Timescale at AWS Summit New York 🤝 Schedule a Meeting!
TimescaleDB - Timeseries database for PostgreSQL Docs
  • Timescale.com
  • Try for free
Get started
Create your first Timescale service
Try the key Timescale features
Start coding with Timescale
About Timescale products
Timescale architecture for real-time analytics
Pricing plans and account management
Changelog
Use Timescale
Hypertables
Hypercore
Continuous aggregates
Tutorials
Integrations
API Reference
Hypertables and chunks
Hypercore
Continuous aggregates
Data retention
Jobs 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
Compression (Old API, replaced by Hypercore)
Distributed hypertables (Sunsetted v2.14.x)
Migrate and sync data to Timescale Cloud
AI and Vector: pgai on Timescale
Other deployment options
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.

Timescale Cloud: Performance, Scale, Enterprise

Self-hosted products

MST

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 or Edit this page in GitHub.

Previoustime_bucket_ngNextmonth_normalize

Related Content

month_normalize()
Normalize a monthly metric based on number of days in month
Hyperfunctions
The full list of hyperfunctions available in Timescale Cloud, with required arguments, returns, and complete use examples
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