Convert string to Date in R: month abbreviated "dd-mmm-YYYY"

Cactus

I have a vector of strings which I need to convert to dates. This only works for some of the dates which are in the format of "dd-mmm-YYYY".

Example: this works: strptime("21-Sep-2017", format = "%d-%b-%Y") This does not work and returns NA: strptime("21-Dec-2017", format = "%d-%b-%Y")

What am I doing wrong or not seeing?

erocoar

This is because your locale is probably one where December is not abbreviated as Dec. Without changing your session settings, you could simply do

lubridate::parse_date_time("21-Dec-2017", orders = "d-b-Y", locale = "us")

[1] "2017-12-21 UTC"

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Convert a string to date Format: DD-MMM-YYYY to date time in Python

How to convert a string to a date from dd mmm yyyy format in SQL Server

Convert Timestamp string (dd MMM yyyy HH:mm:ss) to Date (DD/MM/YY) in Google Sheets

"EEE, dd MMM yyyy hh:mm:ss zzz" string convert to Date

Convert the mysql date format to dd-mmm-yyyy in mysql

Convert string to Datetime format dd-MMM-yyyy issue

Convert string dd/mmm/YYYY to yyyy-mm-dd in pyspark

How to format a DatePicker in WinUI 3 to display date format as: day/month/year (dd/MMM/yyyy)?

how to convert date string in 2014-05-28T10:51:40.3056+01:00 to dd-mmm-yyyy format in ios

Delete date from string date ( [dd-mmm-yyyy hh:mm:ss] using SED

Date convert dd-MMM-yyyy to dd-MM-yyyy in java

How to convert date format from dd-MMM-yyyy to yyyymmdd in Javascript?

convert date format from "mm/dd/yyyy hh:mm:ss a" to "dd MMM yyyy" in swift

How can I convert to date format (DD MMM YYYY) in file without writing to new file the output

How to parse "dd-MMM-yyyy" or "MMM-dd-yyyy" date string using single regular expression?

Parse String dd-MMM-yyyy to Date Object JavaScript without Libraries

How to extract date from a string of format dd-mmm-yyyy in js

convert dd MMM yyyy to unix time

short date in python (dd/mmm/yyyy)

sort array of date of format 'dd/mmm/yyyy'

Format date to DD-MMM-YYYY in Javascript

Check date format is DD-MMM-YYYY

how to parse a "dd/mm/yyyy" or "dd-mm-yyyy" or "dd-mmm-yyyy" formatted date string using JavaScript or jQuery

How to get dd MMM yyyy format? (Month name in capital)

Convert dd/mmm/yyyy to yyyy-mm-dd

Reformatting a Date from DD-MMM-YYYY to YYYYDDMM or YYYYMMDD

Java program to sort a list of date which is in format dd MMM yyyy

How to format date in javascript as DD-MMM-YYYY?

How to get Date in the below Format "dd MMM, yyyy z"