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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:24:41+00:00 2026-06-17T06:24:41+00:00

Given are two timestamps in the format YYYYMMDDHH , which are perfectly parseable by

  • 0

Given are two timestamps in the format YYYYMMDDHH, which are perfectly parseable by DateTime.strptime.

What I want to create is a list of strings in the given format from above in one hour steps, starting from the first date up to the second date.

Example input: 2013011515 and 2013011822.

Expected output: ['2013011515','2013011516','2013011517','2013011518', ... , '2013011820', '2013011820', '2013011821', '2013011822']

Is there any ruby library or core functionality to accomplish this task?

  • 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-17T06:24:43+00:00Added an answer on June 17, 2026 at 6:24 am

    You can use step with an hourly resolution if you use ruby 1.9:

    date1 = DateTime.strptime('2013011522', '%Y%m%d%H')
    date2 = DateTime.strptime('2013011622', '%Y%m%d%H')
    
    date_range = date1.step(date2, 1.0/24).to_a
    

    Alternatively, on ruby 1.8.7, use a loop

    date1 = DateTime.strptime('2013011522', '%Y%m%d%H')
    date2 = DateTime.strptime('2013011622', '%Y%m%d%H')
    
    new_date = date1
    date_range = [date1]
    date_range << (new_date += 1.0/24) while new_date <= date2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to create two equal timestamps for a given day in PHP and
By using normal minus '-' function between two timestamps, the answer given from oracle
I want to order one mysql table by two strtotime timestamps from two different
Given two arrays, how to find the maximum element which is common to both
Given two strings text1 and text2 : public SOMEUSABLERETURNTYPE Compare(string text1, string text2) {
There are two arrays, that are given for $link from foreach . One time
I have a CTE-based query in which I retrieve hourly intervals between two given
I have an array with timestamps. If this timestamps are between two given dates
I have a CTE-based query in which I retrieve hourly intervals between two given
Say that you have a sorted list of n timestamps (Python datetime objects). How

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.