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 8496915
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T23:58:48+00:00 2026-06-10T23:58:48+00:00

I have a good one this time. I need to combine df$Date and df$Time

  • 0

I have a good one this time. I need to combine df$Date and df$Time to Date_Time as below:

df
   Date      Time   Date_Time
    1/2/2012   9     1/2/2012 9:00:00
    1/3/2012   2.3   1/3/2012 2:30:00
    1/4/2012   8     1/4/2012 8:00:00

I am doing this but this code is not working right.

    df$Time<-gsub( '\\.', ':', df$Time)
    df$Time <- paste(df$Time, ":00", sep='')
    df$Date_Time <- paste(df$Date, df$Time, sep=' ')
    df$Date_Time<-strptime(df$Date_Time, format="%Y-%m-%d %H:%M")

Is there an easy and better way to convert date to datetime regardless of having complete H:M:S at the end?

Basically, if the Date_Time is like this:

1/1/2012 9 or 1/1/2012 9.3

Is there way to convert this data to datetime format in R?

  • 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-06-10T23:58:50+00:00Added an answer on June 10, 2026 at 11:58 pm

    Yeah, just do strptime(paste(df$Date, format(df$Time, nsmall=2)), format='%m/%d/%Y %H.%M')

    Edit: changed nsmall to 2

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

IS this straightforward? Does any one have any good examples? All my google searches
Edit: Not JUnit 4 available at this time. Hi there, I have a question
This time I have a question about C++. I'm using Dev-C++ for programming, but
i have take one string array which stored date in format of 2012-04-26T08:38:00. i
So, one problem pattern that I keep coming across and don't have a good
Is it good practice to have one shared SqlConnection object in a .NET application
Anyone have a suggestion for a good utility class that maps values from one
Good Morning. I have two tables, and one references the other. When I insert
I am writing my own blog (every one should, it's good experience). I have
Can I have good example or code about how to use Ajax Datepicker in

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.