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

  • Home
  • SEARCH
  • 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 7056349
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T03:51:24+00:00 2026-05-28T03:51:24+00:00

I have the following data >d 2010-07-02 >t 835 I issue the following command

  • 0

I have the following data

>d
2010-07-02
>t
835

I issue the following command

>dt<-paste(d,t)
>dt
"2010-07-02 835" 

i then issue the following command, and it returns NA as below:

>dtt<-as.POSIXlt(strptime(dt,'%Y-%m-%d %H%M'))
>dtt
 NA

so I made the following change

>t=1001

and now when I run
dt followed by dtt, it works fine, returning

dtt
“2010-07-02 10:01:00”

so, it seems to me that it is having a problem with the first digit of the hour being a 0, which is why when HHMM is less than 1000, it generates NA. can anyone please suggest how I fix this. thanks!

  • 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-28T03:51:25+00:00Added an answer on May 28, 2026 at 3:51 am

    Use sprintf to format your time string before you pass it to as.POSIXlt:

    d <- "2010-07-02"
    h <- 835
    
    dtt <- sprintf("%s %04d", d, h)
    as.POSIXlt(dtt, format="%Y-%m-%d %H%M")
    [1] "2010-07-02 08:35:00"
    

    The string "%s %04d" tells sprintf to concatenate d as a string (%s) and h as a fixed width string of length 4, with leading zeroes (%04d).

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

Sidebar

Related Questions

I have the following data: cust subject date Cust1 Subject1 2010-12-31 21:59:59.000 Cust1 Subject1
I have the following data: transaction <- c(1,2,3); date <- c(2010-01-31,2010-02-28,2010-03-31); type <- c(debit,
i have data in following format: colA colB 2010 10 2010 20 2010 30
Say I have the following data in my table; tran_date withdraw deposit 25/11/2010 0
Visual Studio 2010, Silverlight 4, and C#. I have the following data stored in
I have the following data: transaction <- c(1,2,3); date <- c(2010-01-31,2010-02-28,2010-03-31); type <- c(debit,
I have the following data; ID startDate endDate ----------------------------------------------- 1 2010-03-01 10:00:00 2010-03-01 12:00:00
I have Following dummy table with data: ACID srno date(mm/dd/yyyy) name 3 1 04/12/2010
I have the following json file named json.txt with the following data, {id:99903727,nickname:TEST_MLA_OFF,registration_date:2010-12-03T14:19:33.000-04:00,country_id:AR,user_type:normal,logo:null,points:0,site_id:MLA,permalink:http://perfil.mercadolibre.com.ar/TEST_MLA_OFF,seller_reputation:{level_id:null,power_seller_status:null,transactions:{period:12 months,total:25,completed:25,canceled:0,ratings:{positive:0,negative:0,neutral:1}}},status:{site_status:deactive}}
I have following data frames > head(elo) date elo 1 1921-12-18 1597 2 1922-05-14

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.