1. We have moved to a new forum! There may be a few things not working properly so please let us know if you find a bug. Remember to use the bbCode [ sql ] tag for SQL statements.

compare?

Discussion in 'SQL - Questions and Answers' started by Rakesh, Dec 13, 2006.

  1. Rakesh Guest

    Dialect: SQL 92
    Hi, I want to compare values from 2 dates, periods or years. How do I do that?
  2. Unregistered Guest

    //For Day
    SELECT PkgDate, ExpDate
    FROM TableName
    WHERE (DAY(PkgDate) = DAY(ExpDate))

    //For Year
    SELECT PkgDate, ExpDate
    FROM TableName
    WHERE (Year(PkgDate) = Year(ExpDate))

    //For Month
    SELECT PkgDate, ExpDate
    FROM TableName
    WHERE (month(PkgDate) = month(ExpDate))

Share This Page