Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7062693
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:37:29+00:00 2026-05-28T04:37:29+00:00

I have extracted data to a data frame with mixed format dates that need

  • 0

I have extracted data to a data frame with mixed format dates that need consolidated. The structure of the data frame is as follows:

dateDF <- structure(list(id = 1:7, value = c(5813L, 8706L, 4049L, 5877L, 
1375L, 2223L, 3423L), date = structure(c(4L, 3L, 2L, 1L, 7L, 
6L, 5L), .Label = c("??:?? 05-Dec-11", "??:?? 06-Dec-11", "??:?? 07-Dec-11", 
"??:?? 19-Dec-11", "30/12/2011 16:00", "30/12/2011 16:45", "31/12/2011 19:10"
), class = "factor")), .Names = c("id", "value", "date"), row.names = c(NA, 
-7L), class = "data.frame")

I have used dateDF$date <- str_replace(string=dateDF$date, pattern='\\?\\?\\:\\?\\? ', '12:00 ') to produce:

id  value   date
1   5813    12:00 19-Dec-11
2   8706    12:00 07-Dec-11
3   4049    12:00 06-Dec-11
4   5877    12:00 05-Dec-11
5   1375    31/12/2011 19:10
6   2223    30/12/2011 16:45
7   3423    30/12/2011 16:00

I now need to convert the top 4 style dates with format hh:mm dd-mmm-yy to a format consistent with the bottom three date formats dd/mm/yyyy hh:mm for each case where the first format exists in the column.

Any help is appreciated.

J.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:37:30+00:00Added an answer on May 28, 2026 at 4:37 am

    If you know that you only have those two formats, you can first identify them (the first one has alphabetic characters in it, the other does not) and convert accordingly.

    dateDF$date <- as.POSIXlt( 
      dateDF$date, 
      format = ifelse( 
        grepl("[a-z]", d$date), 
        "%H:%M %d-%b-%y", 
        "%d/%m/%Y %H:%M" 
      ) 
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a pgp-encrypted file that I need to extract data from at runtime.
I have a large data frame that Im working with, the first few lines
I have a large data frame that Im working with, the first few lines
I have a script that needs to extract data temporarily to do extra operations
I have a YQL query that extracts data from a page and returns it
I have an Indian company data set and need to extract the City and
I have a string in c# containing some data i need to extract based
Suppose I have a list of filenames: [exia.gundam, dynames.gundam, kyrios.gundam, virtue.gundam] , or [exia.frame,
Let's say I have some data in R that looks like this: c(0.11, NA,
I have a model that requires loading external data from an auxiliary source. A

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.