DATEDIFF ON MAX DATE

  • think you need an extra closing bracket before Days_with_Voids. currently you just have one.

    )) as Days_with_Voids

  • Yes, As davidandrews13 mentioned closing parenthesis was missing for datediff function

  • Thanks Guys.

    Done the trick

  • Messed up this post - let me explain it better what I am trying to achieve

  • Morning Guys,

    I'm trying to do the following.

    In my SELECT Statement I am using DATEDIFF to calculate some difference in dates. As below -

    SELECT DATEDIFF(day, MAX(dbo.[IH_IH-LOCATION-STAT-HIST].[RECEIVED-KEYS])

    ,MAX(dbo.[IH_IH-LOCATION-STAT-HIST].[READY-TO-LET])) AS 'Days_with_Voids'

    ,DATEDIFF(day, dbo.[IH_RE-TENANCY].[tncy-end]

    ,MAX(dbo.[IH_IH-LOCATION-STAT-HIST].[READY-TO-LET])) AS 'Total_Days_to_RTL'

    I now want to get the difference between these two fields.

    What I have done is place ,'Days_with_Voids' - 'Total_Days_to_RTL' AS 'Difference'

    However I get the following error -

    Server: Msg 403, Level 16, State 1, Line 1

    Invalid operator for data type. Operator equals subtract, type equals varchar.

    Can you please advise how I go about correcting this?

Viewing 5 posts - 1 through 6 (of 6 total)

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