RE: SQL Server 2005: Cannot convert {fn CURDATE()} to "datetime" datatype
- From: stcheng@xxxxxxxxxxxxxxxxxxxx (Steven Cheng[MSFT])
- Date: Wed, 26 Jul 2006 04:22:41 GMT
Hello Michael,
Welcome to the SQL Server MSDN newsgroup.
From your description, I understand you're getting some convertion errorwhen using the CURDATE function in your T-SQL select statement(for SQL
Server 2005).
Based on my understanding, the CURDATE function is an undocumented internal
function which will return the current Datetime's Date part. Since I
haven't found any definite document on its type, I suggest you try
explicitly converting it before use it in your select statement. You can
consider the following options:
1. We can use a temp variable (declare as dateime) to store the CurDate()
return value first and reference that variable in our select statement.
2. We can explicitly convert the CurDate()'s return value to Datetime when
directly embed it into our select statement. e.g
select * from xxxxx where xxxxDate < CONVERT(DATETIME, {fn CURDATE()})
In addition, do you think it's possible that we use the "GetDate" function
to replace the "CurDate" in your scenario? "GetDate" is a documented
function which will be much recommended in our application's T-SQL code.
If you do want to get the Date part only, we can also use T-SQL to convert
the GetDate() result to the date only value. e.g.
CAST( CONVERT( CHAR(8), GetDate(), 112) AS DATETIME)
Hope this helps some. If you stll have any other questions on this, please
feel free to post here.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial
response from the community or a Microsoft Support Engineer within 1
business day is
acceptable. Please note that each follow up response may take approximately
2 business days
as the support professional working with you may need further investigation
to reach the
most efficient resolution. The offering is not appropriate for situations
that require
urgent, real-time or phone-based interactions or complex project analysis
and dump analysis
issues. Issues of this nature are best handled working with a dedicated
Microsoft Support
Engineer by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
.
- Follow-Ups:
- Re: SQL Server 2005: Cannot convert {fn CURDATE()} to "datetime" datatype
- From: Michael Bruegmann
- Re: SQL Server 2005: Cannot convert {fn CURDATE()} to "datetime" datatype
- From: Michael Bruegmann
- Re: SQL Server 2005: Cannot convert {fn CURDATE()} to "datetime" datatype
- References:
- SQL Server 2005: Cannot convert {fn CURDATE()} to "datetime" datatype
- From: Michael Bruegmann
- SQL Server 2005: Cannot convert {fn CURDATE()} to "datetime" datatype
- Prev by Date: SQL Server 2005: Cannot convert {fn CURDATE()} to "datetime" datatype
- Next by Date: Re: SQL Server 2005: Cannot convert {fn CURDATE()} to "datetime" datatype
- Previous by thread: SQL Server 2005: Cannot convert {fn CURDATE()} to "datetime" datatype
- Next by thread: Re: SQL Server 2005: Cannot convert {fn CURDATE()} to "datetime" datatype
- Index(es):
Relevant Pages
|