Date Function for SQL Server 6.5

  • Hi, I am capturing results from "1st day of the month" to "last day of the month".

    How can I replace function to avoid put date manulally.

    --Script which need to be updated to run in SQL-Server 6.5 version

    Select * from depend

    where effdate >='2009-05-01' --1st of current month

    and effdate< '2009-06-01' --1st of next month --I have script for SQL-Server 2000 but not able to run SQL-Server 6.5 and getting error of 'Operand type clash: int is incompatible with datetime'
    --Script is fine in SQL-server 2000
    SELECT * FROM depend
    WHERE EffDate>=DATEADD(month,DATEDIFF(month,0,GETDATE()),0)

    AND EffDate

  • You appear to be missing part of the query after the AND. What's the full query look like?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Oh, yeah.... the other thing to try is changing the "0" date to '1900-01-01' everywhere.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 3 posts - 1 through 2 (of 2 total)

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