Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Allow extract parts from interval type #17392

Closed
rad-pat opened this issue Jan 31, 2025 · 0 comments · Fixed by #17417
Closed

Feature: Allow extract parts from interval type #17392

rad-pat opened this issue Jan 31, 2025 · 0 comments · Fixed by #17417
Assignees
Labels
C-feature Category: feature

Comments

@rad-pat
Copy link

rad-pat commented Jan 31, 2025

Summary
Similar to EXTRACT from timestamp, allow EXTRACT from an interval to give the various parts. For interval type,

EPOCH == total number of seconds
DAY == number of days
HOUR == number of hours
MINUTE == number of minutes
SECOND == number of seconds
MICROSECONDS == seconds * 1,000,000

e.g.

select  EXTRACT(day from '1 day 2 hours 3 minutes'::INTERVAL)
93780

select  EXTRACT(day from '1 day 2 hours 3 minutes'::INTERVAL)
1

select  EXTRACT(hour from '1 day 2 hours 3 minutes'::INTERVAL)
2

select  EXTRACT(minute from '1 day 2 hours 3 minutes'::INTERVAL)
3

SELECT EXTRACT(second from '1 day 02:03:04.1234'::INTERVAL);
4.1234

SELECT EXTRACT(microsecond from '1 day 02:03:04.1234'::INTERVAL);
4123400
@rad-pat rad-pat added the C-feature Category: feature label Jan 31, 2025
@TCeason TCeason self-assigned this Jan 31, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature Category: feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants