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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:17:45+00:00 2026-06-13T07:17:45+00:00

SELECT Asset.AssetID, AnsMaint.Answer, Convert(datetime, AnsMaint.Answer) as maintasdate FROM Asset INNER JOIN AssetAnswer AnsMaint ON

  • 0
SELECT Asset.AssetID, AnsMaint.Answer, Convert(datetime, AnsMaint.Answer) as maintasdate
FROM Asset INNER JOIN 
AssetAnswer AnsMaint ON AnsMaint.AssetID = Asset.AssetID INNER JOIN  
AssetField FldMaint ON FldMaint.AssetFieldID = AnsMaint.AssetFieldID 
WHERE FldMaint.FieldText = 'Maint. Agreement Term' 
AND ISDATE(AnsMaint.Answer) = 1 
AND Convert(datetime, AnsMaint.Answer) < DateAdd(d, 145, GetDate())

I get the error on the last part of the AND. If I comment the AND out, it works fine. My dates in the DB happen to be 10/10/2012 and are valid. IsDate should weed out anything that is not valid.

In DB the results (when I comment out the last line). I’m completely stumped.

106 10/10/2012  2012-10-10 00:00:00.000
115 10/10/2012  2012-10-10 00:00:00.000

MORE interesting tidbits. If I change the last AND line to

AND DateAdd(d, cast(Asset.MaintenanceFreq as int), Convert(datetime, AnsMaint.Answer)) < DateAdd(d, 45, GetDate()) 

it works. If I take out the 2nd parameter (the cast as int) and replace it with a number or a zero, it gives me the same error.

I’m stumped. Any help would be so much appreciated!

Oh, AssetMaint.Answer is a varchar field in the DB nothing I can do about that.

  • 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-13T07:17:46+00:00Added an answer on June 13, 2026 at 7:17 am

    From the description, it sounds like the Answer column contains values for some records which can’t be converted to a date, and SQL is choosing an execution plan which evaluates the CONVERT before the ISDATE.

    Try using a CASE statement for the conversion instead:

    WHERE FldMaint.FieldText = 'Maint. Agreement Term' 
    AND CASE ISDATE(AnsMaint.Answer) 
       WHEN 1 THEN Convert(datetime, AnsMaint.Answer, 103) 
    END < DateAdd(d, 145, GetDate())
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following SQL query: SELECT members.member_ID, members.nick_name FROM orgs INNER JOIN assets
Consider this command, as written here: Command.CommandText = SELECT COUNT(ASSET) AS POSEXISTS FROM POSITIONS
SELECT * From `users` AS `User` LEFT JOIN `selections` AS `Selections` ON (`Selections`.`user_id` =
var temp = (from assetVisit in db.AssetVisits join assetBundle in db.AssetBundles on assetVisit.AssetID equals
SELECT a.tag,CONCAT(u.first_name,' ',u.last_name) FROM assets a LEFT JOIN (SELECT asset_id,assigned_to_id FROM asset_activity WHERE assigned
OK.. I'm stuck. Can someone help me converting this JQL SELECT a FROM Asset
SELECT REPLACE([strUrl], '/myoldurl', '/mynewurl') FROM [UrlRewrite] If strUrl is /myoldurl/myoldurl_something_else , it returns /mynewurl/mynewurl_something_else
SELECT Id,Date,Name FROM people WHERE DATEPART(hh,Date) >= 7 AND DATEPART(hh,Date) <= 8 Order by
select tf.Id,tf.Name,tf.LName,tf.Rank,tf.Category where tf.Id not in (select fighter_id from tbl_player_fighter where league_id=91) and tf.Status
SELECT * FROM list WHERE list_item LIKE %_1375_% returns results it should not. For

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.