Sintax error in a code to get weekly data

  • What is wrong with this code?...it has a sintax erro

    FROM [QAProjTrack].[dbo].[QAPProgressStatus]

    where the_date between (current_date('&Date', 'MM/DD/YYYY')-6)

    and (case when current_date('&Date', 'MM/DD/YYYY') > trunc(sysdate)-1

    then trunc(sysdate)-1

    else current_date('&Date', 'MM/DD/YYYY')

    end)

    Thanks,

  • Besides the fact that there's no Select clause... I'd imagine your error lies somewhere here...

    (case when current_date('&Date', 'MM/DD/YYYY') > trunc(sysdate)-1

    then trunc(sysdate)-1

    else current_date('&Date', 'MM/DD/YYYY')

    end)

    What language is this? What Type of database (oracle, Sql Server, MySQL, PostgreSQL) are you attempting to get this query to run against. Current_date is not a function in SQL server. Neither is sysdate. what exact message are you getting as an error?

    To help us help you read this[/url]For better help with performance problems please read this[/url]

  • It's a SQL database and this is the complete code:

    SELECT [QAProgStatID#]

    ,[ATLAS]

    ,[AtlasType]

    ,[AsbuiltProjectNumber]

    ,[AsbuiltReceivedDate]

    ,[AsbuiltType]

    ,[AsbuiltNumber]

    ,[LinealFeet]

    ,[UserId]

    ,[CadastralTechAssignedDate]

    ,[CadastralTechSubmittedforReview]

    ,[GISReceivedDate]

    ,[GISReviewCompleted]

    ,[CadastralTechReAssignedDate1]

    ,[CadastralTechReSubmittedforReview1]

    ,[GISReceivedDate2]

    ,[GISReviewCompleted2]

    ,[CadastralTechReAssignedDate2]

    ,[CadastralTechReSubmittedforReview2]

    ,[GISReceivedDate3]

    ,[GISReviewCompleted3]

    ,[CadastralTechReAssignedDate3]

    ,[CadastralTechReSubmittedforReview3]

    ,[GISReceivedDate4]

    ,[GISReviewCompleted4]

    ,[FinalCompletionDate]

    ,[PlacedInLibrary]

    ,[ProjectQA]

    FROM [QAProjTrack].[dbo].[QAPProgressStatus]

    where the_date between (current_date('&Date', 'MM/DD/YYYY')-6)

    and (case when current_date('&Date', 'MM/DD/YYYY') > trunc(sysdate)-1

    then trunc(sysdate)-1

    else current_date('&Date', 'MM/DD/YYYY')

    end)

    The error that I'm getting is this one:

    " Msg 156, Level 15, State 1, Line 30

    Incorrect syntax near the keyword 'current_date'. "

  • current_date and sysdate are not functions in SQL server. are you porting this code from another platform, or are those udf's or CLR functions or something else? This really looks like code to access an Oracle database. Or at least those functions exist in Oracle PL/SQL but not in Microsoft's TSQL. If you are porting this from Oracle to SQL Server, you might try the getdate() function instread.

    -Luke.

    To help us help you read this[/url]For better help with performance problems please read this[/url]

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply