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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T01:06:26+00:00 2026-06-12T01:06:26+00:00

I have a data with more that 3 million records having start.time and end.time

  • 0

I have a data with more that 3 million records having start.time and end.time as two of the variables. The first 10 obs are as follows:

   start.date start.time   end.date end.time
1  2012-07-13   15:01:32 2012-07-13 15:02:42
2  2012-07-05   18:26:31 2012-07-05 18:27:19
3  2012-07-14   20:23:21 2012-07-14 20:24:11
4  2012-07-29   16:09:54 2012-07-29 16:10:48
5  2012-07-21   14:58:32 2012-07-21 15:00:17
6  2012-07-04   15:36:31 2012-07-04 15:37:11
7  2012-07-22   18:28:31 2012-07-22 18:28:50
8  2012-07-09   21:08:42 2012-07-09 21:09:02
9  2012-07-05   09:44:52 2012-07-05 09:45:05
10 2012-07-02   18:50:47 2012-07-02 18:51:38

I need to calculate the difference between start.time and end.time.

I used the following code:

mbehave11$diff.time <- difftime(mbehave11$end.time, mbehave11$start.time, units="secs")

But I am getting this error:

Error in as.POSIXlt.character(x, tz, ...) : 
  character string is not in a standard unambiguous format
In addition: Warning messages:
1: In is.na.POSIXlt(strptime(xx, f <- "%Y-%m-%d %H:%M:%OS", tz = tz)) :
  Reached total allocation of 1535Mb: see help(memory.size)
  • 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-12T01:06:27+00:00Added an answer on June 12, 2026 at 1:06 am

    You must turn your strings into date objects before you can do date/time arithmetic. Try this:

    a) Reading your data:

    R> dat <- read.table(textConnection("start.date start.time end.date end.time
    2012-07-13   15:01:32 2012-07-13 15:02:42
    2012-07-05   18:26:31 2012-07-05 18:27:19 
    2012-07-14   20:23:21 2012-07-14 20:24:11"), header=TRUE) 
    

    b) Working on one observation:

     R>  strptime( paste(dat[,1], dat[,2]), "%Y-%m-%d %H:%M:%S")
     [1] "2012-07-13 15:01:32" "2012-07-05 18:26:31" "2012-07-14 20:23:21" 
    

    c) Working on the set, converting to numeric:

     R> as.numeric(difftime(strptime(paste(dat[,1],dat[,2]),"%Y-%m-%d %H:%M:%S"),
                            strptime(paste(dat[,3],dat[,4]),"%Y-%m-%d %H:%M:%S"))) 
     [1] -70 -48 -50
     R> 
    

    Edit Some seven years later by someone else below.

    d) Just to explain the results -70 -48 -50 above take a look at the example row by row:

    [2012-07-13 15:01:32] - [2012-07-13 15:02:42] = -70 seconds,  
    [2012-07-05 18:26:31] - [2012-07-05 18:27:19] = -48 seconds,  
    [2012-07-14 20:23:21] - [2012-07-14 20:24:11] = -50 seconds
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have oracle table that holds more than 30 million records, I need to
I have the below markup that cannot be changed: <div>Some data</div> <span>More data</span> <a>Link
I have a service that will return 0 or more sets of data. The
I have a huge database that has several tables that hold several million records.
I currently have a closure table used for hierarchical data that has 5 million
I have a search page that is tasked with searching 3.5 million records for
I have two tables(InnoDB) one with 15 million records and the other with 14
I have a table that has about 1/2 million records in it. Each month
I have some data with one row of headers and one or more rows
I have a in-line delete button, I want to append more data to the

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.