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
abbreviate: logical value
Example 1: Weekdays function
Python3
date < - as.POSIXlt( "2020-5-19" )
weekdays(date, abbreviate = FALSE)
|
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
abbreviate : logical value
Example 1: Months function
Python3
date < - as.POSIXlt( "2020-5-19" )
months(date, abbreviate = FALSE)
|
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.
Last Updated :
08 Jul, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...