RE: SQL Server 2005: Cannot convert {fn CURDATE()} to "datetime" datatype



Hello Michael,

Welcome to the SQL Server MSDN newsgroup.

From your description, I understand you're getting some convertion error
when 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.

.



Relevant Pages

  • RE: Using BackgroundWorker in a browsers hosted user control
    ... Copy the code in the MSDN sample for BackgroundWorker component (you may ... This ensures the usercontrol hosted in the web page to be loaded ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.framework.clr)
  • RE: Help: Unable to open Web service project in a .net solution.
    ... Welcome to the MSDN newsgroup. ... Microsoft MSDN Online Support Lead ... response from the community or a Microsoft Support Engineer within 1 ...
    (microsoft.public.vsnet.general)
  • RE: web tests in Visual Studio.NET 2005 Team Developer
    ... Can the VS versions that you reference be found in MSDN subscriptions or only ... "Software Tester" version is dedicated to testers which contains all the ... Microsoft MSDN Online Support Lead ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.vsnet.ide)
  • RE: web.config tutorial
    ... you can find the related schema and ... Here is the web url of the MSDN ... Microsoft MSDN Online Support Lead ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.general)
  • RE: MSDTC Error after applying W2K3 SP2
    ... I agree with Florin that the Transaction forum maybe the proper one. ... Microsoft MSDN Online Support Lead ... MSDTC Error after applying W2K3 SP2 ...
    (microsoft.public.dotnet.framework.aspnet)