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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T22:06:01+00:00 2026-05-26T22:06:01+00:00

I have two queries. The first query: select in_gentime from in_time_temp where cardnumber =

  • 0

I have two queries. The first query:

select in_gentime
from in_time_temp
where cardnumber = 'MCL1570'
order by in_gentime

Output is:

2011-10-11 08:06:00.000
2011-10-12 08:35:00.000
2011-10-13 08:21:00.000
2011-10-15 08:21:00.000
2011-10-16 08:21:00.000
2011-10-17 08:21:00.000
2011-10-18 08:21:00.000
2011-10-19 08:21:00.000
2011-10-20 08:21:00.000
2011-10-21 08:21:00.000
2011-10-22 08:21:00.000
2011-10-24 08:21:00.000
2011-10-25 08:21:00.000
2011-10-26 09:00:00.000
2011-10-27 09:00:00.000
2011-10-28 09:00:00.000
2011-10-29 09:00:00.000
2011-10-31 09:00:00.000

The second query:

select out_gentime
from out_time_temp
where cardnumber = 'MCL1570'
order by out_gentime

Output is:

2011-10-11 22:02:00.000
2011-10-12 21:14:00.000
2011-10-14 21:59:00.000
2011-10-15 21:59:00.000
2011-10-16 21:59:00.000
2011-10-17 21:59:00.000
2011-10-18 21:59:00.000
2011-10-19 21:59:00.000
2011-10-20 21:59:00.000
2011-10-21 21:59:00.000
2011-10-22 21:59:00.000
2011-10-24 21:59:00.000
2011-10-25 21:59:00.000
2011-10-26 18:15:00.000
2011-10-27 18:15:00.000
2011-10-28 18:15:00.000
2011-10-29 23:15:00.000
2011-10-31 22:15:00.000

I need to identify records that have DATE values that appear in one table but not the other. I want to ignore the specific TIME. For example, I want to only return these 2 records:

2011-10-13 08:21:00.000
2011-10-14 21:59:00.000 

How can I write a query to do this?

  • 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-26T22:06:02+00:00Added an answer on May 26, 2026 at 10:06 pm

    If you use a FULL OUTER JOIN, you can join together the list of dates and then just pick the records where one or the other is NULL:

    SELECT COALESCE(i.in_gentime, o.out_gentime)  -- pick first non-null value
    FROM in_time_temp i
    FULL OUTER JOIN out_time_temp o 
        ON  CAST(CONVERT(varchar(8), i.in_gentime,  112) AS datetime) = 
            CAST(CONVERT(varchar(8), o.out_gentime, 112) AS datetime)
        AND i.cardnumber = o.cardnumber
    WHERE (i.in_gentime is null or o.out_gentime IS NULL)
    AND   (i.cardnumber = 'MCL1750' OR o.cardnumber = 'MCL1750')
    

    Update. Nathan, here is the full test code, I’m not sure why you are not getting results, but this returns 4 records when I run it:

    CREATE TABLE in_time_temp  
    (
        in_gentime   datetime,
        cardnumber   nvarchar(50)
    )
    insert into in_time_temp values('2011-10-11 08:06:00.000', 'MCL1750')
    insert into in_time_temp values('2011-10-12 08:35:00.000', 'MCL1750')
    insert into in_time_temp values('2011-10-13 08:21:00.000', 'MCL1750')
    insert into in_time_temp values('2011-10-15 08:21:00.000', 'MCL1750')
    insert into in_time_temp values('2011-10-16 08:21:00.000', 'MCL1750')
    insert into in_time_temp values('2011-10-17 08:21:00.000', 'MCL1750')
    
    
    CREATE TABLE out_time_temp
    (
        out_gentime    datetime,
        cardnumber   nvarchar(50)
    )
    insert into out_time_temp values('2011-10-11 22:02:00.000', 'MCL1750')
    insert into out_time_temp values('2011-10-12 21:14:00.000', 'MCL1750')
    insert into out_time_temp values('2011-10-14 21:59:00.000', 'MCL1750')
    insert into out_time_temp values('2011-10-15 21:59:00.000', 'MCL1750')
    insert into out_time_temp values('2011-10-16 21:59:00.000', 'MCL1750')
    insert into out_time_temp values('2011-10-17 21:59:00.000', 'MCL1750')
    insert into out_time_temp values('2011-10-18 21:59:00.000', 'MCL1750')
    insert into out_time_temp values('2011-10-19 21:59:00.000', 'MCL1750')
    
    
    SELECT COALESCE(i.in_gentime, o.out_gentime)  -- pick first non-null value
    FROM in_time_temp i
    FULL OUTER JOIN out_time_temp o 
        ON  CAST(CONVERT(varchar(8), i.in_gentime,  112) AS datetime) = 
            CAST(CONVERT(varchar(8), o.out_gentime, 112) AS datetime)
        AND i.cardnumber = o.cardnumber
    WHERE (i.in_gentime is null or o.out_gentime IS NULL)
    AND   (i.cardnumber = 'MCL1750' OR o.cardnumber = 'MCL1750')
    

    And the output is:

    2011-10-13 08:21:00.000
    2011-10-14 21:59:00.000
    2011-10-18 21:59:00.000
    2011-10-19 21:59:00.000
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two seperate queries: SELECT `ad_general`.`id` FROM (`ad_general`) WHERE `ad_general`.`city` = '708' ORDER
I have two sql queries: $query0=mysql_query(SELECT caseNumber FROM shipped_data WHERE palette='P0' AND shipInvoiceNumber='2011/229'); $query1=mysql_query(SELECT
I have two queries. The first query looks like this : SELECT subject_id, period,
I have two queries, as following: SELECT SQL_CALC_FOUND_ROWS Id, Name FROM my_table WHERE Name
I have two mysql queries: $sql = SELECT * FROM content WHERE threadName LIKE
I have these two queries to test my output SELECT DISTINCT( providerId ), SUM((
I have the following two queries: select count(*) from segmentation_cycle_recipients scr , segmentation_instance si
I have written two queries. query 1: select stock_id from_id, nvl(lead(stock_id, 1, null) over
I have two queries serving the same purpose. SELECT * FROM #user INNER JOIN
I have two queries that are basically the same: OLD TRANSACTIONS QUERY SELECT t.payment_method,

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.