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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T03:07:58+00:00 2026-06-18T03:07:58+00:00

I have been trying to make simple queries with two conditions with start and

  • 0

I have been trying to make simple queries with two conditions with start and end datetimes.

In development mode I don’t have any problem and it seems to work well (SQLite)

In production mode however I have the following error:

 ActionView::Template::Error (PG::Error: ERROR:  syntax error at or near "end"
 LINE 1: ...ions"  WHERE (start >= '2013-01-30T10:12:24Z' AND end >= '20...
: SELECT COUNT(*) FROM "missions"  WHERE (start >= '2013-01-30T10:12:24Z' AND end >= '2013-01-30T10:12:24Z')):
                                                              ^
     6:                 <li class="mission clearfix">
     1: <h4 class="heading-sep"><%= t(".upcoming_missions")%></h4>
     2: <div class="missions-timeline">
     3:     <ul class="mission-list">
   app/views/users/show.html.erb:12:in `_app_views_users_show_html_erb___1717297229253226868_63256380'
     7:                     <div class="mission-wrap clearfix">
     4:         <% if @upcoming_missions.any? %>

     5:             <% @upcoming_missions.each do |mission| %>
   app/views/users/_mission_timeline.html.erb:4:in `_app_views_users__mission_timeline_html_erb__2786253018340202740_62779040'

In my controller I have the following queries:

@upcoming_missions = Mission.where("start >= ? AND end >= ?", Time.now, Time.now).order("created_at DESC")

@current_missions = Mission.where("start <= ? AND end >= ?", Time.now, Time.now).order("created_at DESC")

@past_missions = Mission.where("start <= ? AND end <= ?", Time.now, Time.now).order("created_at DESC")

I tried other suggestions by including .utc in case PG reads time differently than SQLite… but I am not sure where the problem is.

Thank you for your help

Aurelien

  • 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-18T03:07:59+00:00Added an answer on June 18, 2026 at 3:07 am

    The solution to the problem is that the word end is a reserved keyword for PostgreSQL. Thank you Micapam for your answers and link.

    In my case, my Missions table had datetime columns named start and end. When running with SQLite in development mode, it was not returning any errors and was sorting my missions the right way. Strangely enough, end is also a reserved keyword in SQLite but was still letting me run my queries.

    In order to solve the problem, I simply renamed my columns in a migration

    class ChangeStartAndEndFromMission < ActiveRecord::Migration
      def change
        change_table :missions do |t|
          t.rename :start, :start_time
          t.rename :end, :end_time
        end
      end
    end
    

    It is good to check out these reserved keywords to make sure there are no conflicts.

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

Sidebar

Related Questions

I have been trying to make an init script using start-stop-daemon. I am stuck
for some days now I have been trying to make a simple mod_rewrite rule
I am new to Java and have been trying to make some simple games
I have been trying to make a StringTable class that holds a simple unordered_map<string,
I have been experiencing some frustrations trying to make a simple Oracle cursor retrieval
For quite awhile I have been trying to make a simple game in Java
I have been trying to make a simple Spring project using Eclipse and Maven
I have been trying to make a simple app with 3 fields like this:
I have been trying to make a script that compares two images in HTML5
Have been struggling all day trying to make this simple example work using socket.io.

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.