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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:30:05+00:00 2026-05-22T16:30:05+00:00

I need to do a query like this select * from calendar where (select

  • 0

I need to do a query like this

select * from calendar where (select to_char(now(), 'day')) = true;

but this is invalid and fails with ERROR: failed to find conversion function from unknown to boolean.

The query I’m trying write, when run today would boil down to

select * from calendar where thursday = true;

But tomorrow, it should be

select * from calendar where friday = true;

The table has this schema

mbta=# \d calendar
             Table "public.calendar"
   Column   |          Type          | Modifiers 
------------+------------------------+-----------
 service_id | character varying(255) | not null
 monday     | boolean                | 
 tuesday    | boolean                | 
 wednesday  | boolean                | 
 thursday   | boolean                | 
 friday     | boolean                | 
 saturday   | boolean                | 
 sunday     | boolean                | 
 start_date | integer                | 
 end_date   | integer                | 

How can I write this query correctly?

  • 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-22T16:30:05+00:00Added an answer on May 22, 2026 at 4:30 pm

    That’s an ugly schema… A bunch of alternatives:

    1. Replace ‘monday, tuesday… ‘ fields by a single integer field, to be interpreted as a bit mask – or use the bit-string data type

    2. Replace them by a single field that contatins an array of integers (days of week).

    3. Denormalize to an extra table, with a single day_of_week field and a FK to your calendar table.

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

Sidebar

Related Questions

I need to make a query like this: SELECT PNPDeviceID FROM Win32_NetworkAdapter WHERE AdapterTypeId
I need to do a query like this: SELECT wposts.ID FROM posts wposts WHERE
Hi I need a query like this select count(id) from employee where.. => gives
Say I have a query like this: SELECT * FROM my_table WHERE name =
I have a query like this: SELECT title,id FROM table1 WHERE id IN ('2','7','4','10')
I have a query like this: select data_name into v_name from data_table where data_table.type
Let us say I have a query like this: SELECT * FROM ( SELECT
I have a simple sql query that goes like this: SELECT * FROM leaderboard
I've done a query like this : SELECT Code, kind, SUM(valP) AS value FROM
Is there a better way of doing a query like this: SELECT COUNT(*) FROM

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.