R/separate_YMD.R

Defines functions separate_YMD

Documented in separate_YMD

#' Separate Year/Month/Day
#' 
#' \code{separate_YMD} contains helper functions to separate an input date into
#'  year, month, and day.
#'
#' @param d is an input date.
#' 
#' @return an array contains year, month, date of the input date
#' \code{d}.

separate_YMD <- function(d){
  
  ## valueDate format valueDate = "2008-02-01"
  
  dateYear <- as.numeric(format(as.Date(d), "%Y"))
  dateMonth <- as.numeric(format(as.Date(d), "%m"))
  dateDay <- as.numeric(format(as.Date(d), "%d"))
  return(c(dateYear, dateMonth, dateDay))
}

Try the creditr package in your browser

Any scripts or data that you put into this service are public.

creditr documentation built on May 29, 2017, 8:46 p.m.