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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:52:05+00:00 2026-05-11T14:52:05+00:00

Along the same vein as the questions asked yesterday, I have another count if

  • 0

Along the same vein as the questions asked yesterday, I have another ‘count if’ dilemma. Now I need to pull a count of the condition entries that meet the following parameters:

  1. ConditionLevelEntryID = 189
  2. CheckoffDate is > 14 days from ConditionEntryDateTime
  3. CheckoffDate IS NULL and ConditionEntryDateTime is > 14 days old

I have attempted the query (below) which doesn’t work. The error returned is below the query. Please help me refine the query to get an accurate count. Thanks in advance.

select Count(*) from conditionentrytable c where conditionlevelentryid=189     and      ((c.checkoffdate IS NULL      and      convert(varchar(12),DATEADD(day,14,c.conditionentrydatetime)))     or      DATEDIFF(dd,c.checkoffdate,c.conditionentrydatetime)>14) 

Server: Msg 170, Level 15, State 1, Line 7 Line 7: Incorrect syntax near ‘)’.

  • 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. 2026-05-11T14:52:06+00:00Added an answer on May 11, 2026 at 2:52 pm

    Try this:

    SELECT  COUNT(*) FROM    conditionentrytable c WHERE   conditionlevelentryid=189         AND DATEDIFF(dd, COALESCE(c.checkoffdate, GETDATE()),c.conditionentrydatetime) > 14 

    , or even better:

    SELECT  COUNT(*) FROM    conditionentrytable c WHERE   conditionlevelentryid=189         AND c.conditionentrydatetime > COALESCE(c.checkoffdate, GETDATE()) - 14 

    The latter query will use a composite index on (conditionlevelentryid, conditionentrydatetime) if you have one, which will most probably greatly improve the query performance.

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

Sidebar

Related Questions

I have an STL list of pointers, along with another pointer of the same
Question i asked earlier along the same lines - jQuery - Selecting a child
Despite many posts I have looked through being of along the same lines as
I'm trying to make two Kinects getting along under the same application. I've tried
I have a long string, the format will be same of this string but
I have two Activities along with one Application class, and whenever I call my
Along the same lines as this question , I want to call acts_as_reportable inside
Along the same lines that for java centric applications, Play framework is stateless and
So I have close to 300 variables (just right now), and I have numerically
Along the same lines as to what was described in conversion to ‘size_t’ 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.