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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T13:15:05+00:00 2026-06-18T13:15:05+00:00

R’s base strptime function is giving me output I do not expect. This works

  • 0

R’s base strptime function is giving me output I do not expect.

This works as expected:

strptime(20130203235959, "%Y%m%d%H%M%S")
# yields "2013-02-03 23:59:59"

This too:

strptime(20130202240000, "%Y%m%d%H%M%S")
# yields "2013-02-03"

…but this does not. Why?

strptime(20130203000000, "%Y%m%d%H%M%S")
# yields NA

UPDATE

The value 20130204000000 showed up in a log I generated on a Mac 10.7.5 system using the command:

➜  ~  echo `date +"%Y%m%d%H%M%S"`
20130204000000

UPDATE 2

I even tried lubridate, which seem to be the recommendation:

> parse_date_time(c(20130205000001), c("%Y%m%d%H%M%S"))
 1 parsed with %Y%m%d%H%M%S
[1] "2013-02-05 00:00:01 UTC"
> parse_date_time(c(20130205000000), c("%Y%m%d%H%M%S"))
1 failed to parse.
[1] NA

…and then funnily enough, it printed out “00:00:00” when I added enough seconds to now() to reach midnight:

> now() + new_duration(13000)
[1] "2013-02-10 00:00:00 GMT"
  • 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-18T13:15:07+00:00Added an answer on June 18, 2026 at 1:15 pm

    I should use character and not numeric when I parse my dates:

    > strptime(20130203000000, "%Y%m%d%H%M%S")    # No!
    [1] NA
    > strptime("20130203000000", "%Y%m%d%H%M%S")  # Yes!
    [1] "2013-02-03"
    

    The reason for this seems to be that my numeric value gets cast to character, and I used one too many digits:

    > as.character(201302030000)
    [1] "201302030000"
    > as.character(2013020300000)
    [1] "2013020300000"
    > as.character(20130203000000)
    [1] "2.0130203e+13"       # This causes the error: it doesn't fit "%Y%m%d%H%M%S"
    > as.character(20130203000001)
    [1] "20130203000001"      # And this is why anything other than 000000 worked.
    

    A quick lesson in figuring out the type you need from the docs: In R, execute help(strptime) and see a popup similar to the image below.

    • The red arrow points to the main argument to the function, but does not specify the type (which is why I just tried numeric).
    • The green arrow points to the type, which is in the document’s title.

    enter image description here

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need a function that will clean a strings' special characters. I do NOT
I'm not entirely sure how I managed to jack this up. http://pretty-senshi.com If you
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
This could be a duplicate question, but I have no idea what search terms

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.