DateConversion: Conversion between Different Date Format

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

DateConversion was used to read and output the date variable with your preferred format.

Usage

1
DateConversion(DateVar,DateIn,DateOut)

Arguments

DateVar

Specify your date variable.

DateIn

Specify the date format for your original variable,e.g.%m/%d/%Y.

DateOut

Specify the date format that you hope to output,e.g.%d/%m/%Y.

Details

DateConversion is an easy function to convert a date variable between different formats,which is very useful for your manipulation on a dataset with date variables without time inside.

Value

DateConversion returns the date format that you expected directly.

Note

For dates, More detailes,see above reference.

Author(s)

Zhijie Zhang, epistat@gmail.com

References

Spector P.Data Manipulation with R.,Springer Science+Business Media,LLC. 2008.(Chapter4:Dates.)

See Also

as.POSIX* for Date-time Conversion Functions #as.Date,Sys.Date,POSIXct,POSIXlt #Dates for dates without times. #strptime for conversion to and from character representations. #Sys.time for clock time as a POSIXct object. #difftime for time intervals. #cut.POSIXt, seq.POSIXt, round.POSIXt and trunc.POSIXt for methods for these classes. #weekdays.POSIXt for convenience extraction functions

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
## Not run: 
#Example 1
a<-"10/20/1999"
DateConversion(a,DateIn="%m/%d/%Y",DateOut="%d/%m/%Y")
#Example 2
b<-"27/12/2000"
DateConversion(b,DateIn="%d/%m/%Y",DateOut="%m/%d/%Y")
#Example 3
c<-"20001223"
Date_New1<-DateConversion(c,DateIn="%Y%m%d",DateOut="%m/%d/%Y")
Date_New1
Date_New2<-DateConversion(c,DateIn="%Y%m%d",DateOut="%d/%m/%Y")
Date_New2

## End(Not run) 

stam documentation built on May 2, 2019, 3:28 p.m.

Related to DateConversion in stam...