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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:26:28+00:00 2026-06-03T08:26:28+00:00

I have two date and time columns in my database. I want to get

  • 0

I have two date and time columns in my database. I want to get rows where date is greater than or equal to current date and current time

I have used below query to get result

SELECT DISTINCT     
A.appt_fromUser,A.date,A.time,A.appt_styleType,B.*,A.appt_shoutID,A.shout_status 
from appoint_db A 
INNER JOIN checkedin_db B ON A.appt_id=B.appid 
where A.appt_toUser='$userid' 
and A.date>='$date' 
and InChair='0' 
and A.time>='$time'

However this isn’t working as I’d hoped.

Eg, if I have two rows:

2012/05/30 Time:6.00
2012/05/30 Time:13.00

And I query this with date of 2012/05/02 and Time:12:00, it returns only only the row where the time is greater than 12:00

  • 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-03T08:26:29+00:00Added an answer on June 3, 2026 at 8:26 am

    You should only check the time if the date is the same as the one you’re checking against.

    SELECT DISTINCT     
    A.appt_fromUser,A.date,A.time,A.appt_styleType,B.*,A.appt_shoutID,A.shout_status
    from appoint_db A
    INNER JOIN checkedin_db B ON A.appt_id=B.appid 
    where A.appt_toUser='$userid'
    and   InChair='0'
    and (
           A.date>'$date'
           OR (
               A.date = '$date'
               AND
               A.time>='$time'
           )
        )
    

    You could also concatenate the date and time before selecting. I wouldn’t though (might not work with some locales).

    SELECT DISTINCT
    A.appt_fromUser,A.date,A.time,A.appt_styleType,B.*,A.appt_shoutID,A.shout_status
    from appoint_db A
    INNER JOIN checkedin_db B ON A.appt_id=B.appid
    where A.appt_toUser=1
    and InChair='0'
    AND CONCAT(A.date, ' ', A.time) >= '$date $time'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have 4 columns in my database UserName, Date, Time, LoginType UserName is a
I have two choices of storing date and time in my database. Generate the
I have two date entities, start_date and end_date and now I want to find
I have two dates: how do I compare which one is greater date in
I have a grid named 'GridView1' contains two columns 'Date' and 'Session Details' I
I'd like to have two columns in a database, one for tracking whether or
I have two tables in my database which have a one-to-one relationship. I want
What I have : A C# database query that returns two columns, one of
I want to have one table with two TIMESTAMP columns. One column to keep
I have two separate columns within the same table in my database. Both of

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.