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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T14:43:28+00:00 2026-05-27T14:43:28+00:00

It seems that ActiveRecord and Ruby’s Time object doesn’t play nice with times that

  • 0

It seems that ActiveRecord and Ruby’s Time object doesn’t play nice with times that are over 24:00. However my database has a lot of those, as they represent a time after midnight but considered to be on the same day. This is a design decision of my data provider:

Note: Trips that span multiple dates will have stop times greater than
24:00:00. For example, if a trip begins at 10:30:00 p.m. and ends at
2:15:00 a.m. on the following day, the stop times would be 22:30:00
and 26:15:00. Entering those stop times as 22:30:00 and 02:15:00 would
not produce the desired results.

How do I deactivate this “validation” of my Time objects? It was suggested that I write my time field as a varchar within the MySQL query but I’m looking for a solution that doesn’t make the database intervene.

UPDATE: Regarding the relevance of keeping the > 24:00 format, querying and asc ordering all the stop_times for a stop using that format would return something like: 23:45, 23:54, 24:35, 24:55, 25:15, which is the actual order in which the next buses are coming.

Whereas going the other way would return: 0:35, 0:55, 1:15, 23:45, 23:54 (this is wrong, the first 3 stop_times are supposed to be sorted after the last 3).

  • 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-27T14:43:29+00:00Added an answer on May 27, 2026 at 2:43 pm

    Although @Tilo is right that this is probably not the best time format there is, I had to stick to them and so ended up using raw SQL to convert the time column into a string:

    sql = "SELECT CONVERT(stop_time, CHAR) as stop_time from stop_times"
    stop_times = ActiveRecord::Base.connection.select_all sql
    time = stop_times[0]['stop_time'] # => returned as a string
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

It seems that a List object cannot be stored in a List variable in
I have a Ruby on Rails project that has been untouched for a while,
Seems that requirements on safety do not seem to like systems that use AI
Seems that even after unchecking the option in the PyDev/Debug preferenecs pane to launch
It seems that it is impossible to capture the keyboard event normally used for
It seems that Silverlight/WPF are the long term future for user interface development with
It seems that most of the installers for Perl are centered around installing Perl
It seems that anyone can snoop on incoming/outgoing .NET web service SOAP messages just
It seems that C# 3 hit me without me even noticing, could you guys
It seems that when I use a tool (such as winmerge) to update my

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.