SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 DateTime Conversion
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

planetoneautomation
Yak Posting Veteran

98 Posts

Posted - 11/13/2012 :  15:48:30  Show Profile  Reply with Quote
In my SELECT clause I have:

MAX(RN_EXECUTION_DATE) AS 'MAXDATE',
MAX(RN_EXECUTION_TIME) AS 'MAXTIME',


... and in my WHERE clause I have:
RN_EXECUTION_DATE = 'MAXDATE' AND
RN_EXECUTION_TIME = 'MAXTIME'


When executed, I get "Conversion failed when converting date and/or time from character string".

I looked at using CONVERT but can't seem to make it work. And, is it the 'MAXDATE' and 'MAXTIME' from the SELECT clause that needs conversion? Or is it something in the WHERE clause?

tkizer
Almighty SQL Goddess

USA
37129 Posts

Posted - 11/13/2012 :  15:50:51  Show Profile  Visit tkizer's Homepage  Reply with Quote
MAXDATE/MAXTIME in your SELECT are just aliases. The WHERE clause is why you are getting that error. You can't specify the MAXDATE/MAXTIME aliases as that's where data goes. If you want it equal to MAXDATE/MAXTIME, you'll need a subquery.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000