Open In App

Determine the Quarter in which the Specific Date lies in R Programming – quarters() Function

Improve
Improve
Like Article
Like
Save
Share
Report

quarters() function in R Language is used to determine the quarter in which a specific date passed to it as argument lies.

Syntax: quarters(date)

Parameters:
date: Date to be checked

Example 1:




# R program to find the quarter 
# of a specific date
  
# Specifying the date
date <- as.POSIXlt("2020-06-23")
date
  
# Calling quarters() function
quarters(date)


Output:

[1] "2020-06-23 UTC"
[1] "Q2"

Example 2:




# R program to find the quarter 
# of a specific date
  
# Specifying the date
date <- as.POSIXlt("1994-01-17")
date
  
# Calling quarters() function
quarters(date)


Output:

[1] "1994-01-17 UTC"
[1] "Q1"

Last Updated : 24 Jun, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads