Finding Day and Month on a Specific Date in R Language – weekday() and month() function

weekdays() function in R Language is used to find out a day on a specific date and return as a string.

Syntax:
weekdays(date)

Parameters:
x: date
abbrevate: logical value

Example 1: Weekdays function

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to illustrate
# weekday function 
  
# Create example date
date <- as.POSIXlt("2020-5-19"
  
# Apply weekdays function
weekdays(date, abbreviate = FALSE) 

chevron_right


Output:



Tuesday

Here in the above code we have created an example date and using the weekdays() function found the day on that date.

months() Function

months() function is used to find out the month on a specific date and return as a string.

Syntax:
months(date)

Parameters:
x : date
abbrevate : logical value

Example 1: Months function

filter_none

edit
close

play_arrow

link
brightness_4
code

# R program to illustrate
# months function 
  
# Create example date
date <- as.POSIXlt("2020-5-19"
  
# Apply months function
months(date, abbreviate = FALSE)                            

chevron_right


Output:

May

Here in the above code we have created an example date and found out the month on that particular date using months() function.

My Personal Notes arrow_drop_up

Recommended Posts:


Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.