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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:04:53+00:00 2026-06-05T08:04:53+00:00

Every once in a while I find a real head scratcher… Any ideas what

  • 0

Every once in a while I find a real head scratcher… Any ideas what is going on here?

> a = strptime("2003-11-01", "%Y-%m-%d")
> b = strptime("2004-01-31", "%Y-%m-%d")
> unlist(a)
  sec   min  hour  mday   mon  year  wday  yday isdst 
    0     0     0     1    10   103     6   304     0 
> unlist(b)
  sec   min  hour  mday   mon  year  wday  yday isdst 
    0     0     0    31     0   104     6    30     0 
> a$mon = a$mon-1
> b$mon = b$mon-1
> a=as.POSIXlt(as.POSIXct(a))
> b=as.POSIXlt(as.POSIXct(b))
> a
[1] NA
> b
[1] "2003-12-31 PST"
> unlist(a)
  sec   min  hour  mday   mon  year  wday  yday isdst 
   NA    NA    NA    NA    NA    NA    NA    NA    -1 
> unlist(b)
  sec   min  hour  mday   mon  year  wday  yday isdst 
    0     0     0    31    11   103     3   364     0 

Why can I edit b but not a? I feel like I must be missing something.

  • 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-05T08:04:55+00:00Added an answer on June 5, 2026 at 8:04 am

    This (a) works for me with the R and session details as below:

    > a$mon = a$mon-1
    > a=as.POSIXlt(as.POSIXct(a))
    > a
    [1] "2003-10-01 01:00:00 BST"
    > unlist(a)
      sec   min  hour  mday   mon  year  wday  yday isdst 
        0     0     1     1     9   103     3   273     1
    

    Without any further information as per your locale and time zone settings etc, I would have to guess that in your locale/time zone that the date/time indicated by a after you subtracted 1 from the $mon element didn’t exist. R is pretty clever about these things but time zones and locales often catch people out.

    The real question is why are you using a date/time object when you are handling just dates?
    a <- as.Date("2003-11-01", "%Y-%m-%d") would be sufficient in this example.

    Details of my R session:

    > sessionInfo()
    R version 2.15.0 Patched (2012-04-14 r59019)
    Platform: x86_64-unknown-linux-gnu (64-bit)
    
    locale:
     [1] LC_CTYPE=en_GB.utf8       LC_NUMERIC=C             
     [3] LC_TIME=en_GB.utf8        LC_COLLATE=en_GB.utf8    
     [5] LC_MONETARY=en_GB.utf8    LC_MESSAGES=en_GB.utf8   
     [7] LC_PAPER=C                LC_NAME=C                
     [9] LC_ADDRESS=C              LC_TELEPHONE=C           
    [11] LC_MEASUREMENT=en_GB.utf8 LC_IDENTIFICATION=C      
    
    attached base packages:
    [1] stats     graphics  grDevices utils     datasets  methods  
    [7] base     
    
    other attached packages:
    [1] ggplot2_0.9.1
    
    loaded via a namespace (and not attached):
     [1] colorspace_1.1-1   dichromat_1.2-4    digest_0.5.2      
     [4] grid_2.15.0        labeling_0.1       MASS_7.3-18       
     [7] memoise_0.1        munsell_0.3        plyr_1.7.1        
    [10] proto_0.3-9.2      RColorBrewer_1.0-5 reshape2_1.2.1    
    [13] scales_0.2.1       stringr_0.6        tools_2.15.0
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using Win Server 2003 we send once every while we send out 200k+ emails
Every once in a while I find myself typing a one-off script to import
Every once and a while I get this error in IE when making an
Im using Visual studio 2008. Every once in a while files that exist in
In this very simple code example, messages get lost every once in a while.
Every once in a while, typically when I stop debugging in our UI assembly,
Every once in a while I'm editing some long pair of if-then-else statements (or
We are using axis for webservice communication between different system in house. Every once
I have a web scraping script that gets new data once every minute, but
Suppose I want to run the following method foo() once every hour in Grails:

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.