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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T12:39:43+00:00 2026-06-04T12:39:43+00:00

In my SQLite-DB I want to select all entries on a monday. How can

  • 0

In my SQLite-DB I want to select all entries on a monday.

How can I do it with Sequel?

A test example:

require 'sequel'

DB = Sequel.sqlite()#'test.db')
DB.create_table(:days) do
    String :text
    Date  :start
end

Date.today.upto(Date.today + 30){|d|
  DB[:days].insert( :text => d.strftime("%Y-%m-%d day %w in week %W"), :start => d)
}

How can I select all mondays?

In native SQL I can do:

select * from days where strftime("%w", start) = "1"

Using this, I can define a view and select for it:

DB.run('create view mondays as select * from days where strftime("%w", start) = "1"')
p DB[:mondays].all

But I would like to use it from Sequel.

I tried

sel = DB[:days].filter{ start.strftime("%w", :start) == '1' }  
#NoMethodError

sel = DB[:days].filter{ Sequel::SQL::Function.new(:strftime, "%w", :start) == '1' }
#SELECT * FROM `days` WHERE (1 = 0)

but without success.

Are there any other solutions?

I’m looking also for a possibility to select items by hour of day (all items with a timestamp, and then from 12:00-13:00 …) I think this is the same problem and a solution for the day of week-selection will also solve my other problem.

  • 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-04T12:39:44+00:00Added an answer on June 4, 2026 at 12:39 pm

    Here are the problems with your examples:

    sel = DB[:days].filter{ start.strftime("%w", :start) == '1' }  
    #NoMethodError
    

    This uses a virtual row, so calling start returns a Sequel::SQL::Identifier. The Sequel::SQL::Identifier#strftime method does not exist, hence the NoMethodError.

    sel = DB[:days].filter{ Sequel::SQL::Function.new(:strftime, "%w", :start) == '1' }
    #SELECT * FROM `days` WHERE (1 = 0)
    

    This fails because you are using ==. Sequel doesn’t override ==, and ruby’s default == returns false. On SQLite, Sequel represents false as (1 = 0).

    This should work:

    sel = DB[:days].filter{{strftime("%w", :start) => '1'}}
    # SELECT * FROM `days` WHERE (strftime('%w', `start`) = '1')
    

    This uses a hash (the inner {}) inside a virtual row block (the outer {}). In Sequel, equality is represented by hashes.

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

Sidebar

Related Questions

I want to convert sqlite query to Ormlite query. SELECT * FROM Test where
I'm trying to do a raw query in SQLite. I want to select all
I'm trying to write a SQLite query in Android where I select all rows
When you want to write a query in Python that will select (from SQLite
Okay, so I'm doing a search in a SQLite database for all entries in
I want to run a SELECT ... LIKE query in SQLite that is case-sensitive.
I want to query all rows from my sqlite database and then pass it
I am starting a project from scratch in WPF using SQLite.I want to use
I have an sqlite database I want to distribute with my application. It's about
I have normal sqlite database and want to use fts3. As mentioned in http://www.sqlite.org/fts3.html

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.