Results 1 to 4 of 4

Thread: Incorrect syntax near 'ProjectOverview'.

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2011
    Posts
    58

    Incorrect syntax near 'ProjectOverview'.

    Hello,
    Please help me with my problem, this is the simple select statement I have for target bid date:
    Code:
    ProjectOverview.[Target Event Date - Date] AS [Target Bid Date]
    now, I want to ask how can I select the latest target event date and if value is null, put "no date" caption

    i tried doing this:
    Code:
    isnull MAX(ProjectOverview.[Target Event Date - Date],'INACTIVE') AS [Target Bid Date]
    but it says:
    Incorrect syntax near 'ProjectOverview'.
    String cannot be converted to date

    Thank you very much and I am hoping someone can help me.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Incorrect syntax near 'ProjectOverview'.

    You are getting the MAX of a date column so the value returned must be either type date or NULL. You can't substitute a string where a date is expected. It would make far more sense to just return NULL from the database and then display a place-holder at the application level.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2011
    Posts
    58

    Re: Incorrect syntax near 'ProjectOverview'.

    Okay how about I get only the max of date?

    Code:
    ProjectOverview.[Target Event DATE - DATE] AS [Target Bid DATE]
    I get below error when i try this code:
    Code:
    Max(ProjectOverview.[Target Event DATE - DATE]) AS [Target Bid DATE]

    Thank you jmcilhinney

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Incorrect syntax near 'ProjectOverview'.

    You didn't post the error message. Also is 'Target Event DATE - DATE' one column or two? If it's one the it's an abominable name. If it's two, why is it grouped as one?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width