Home Forums SQL Server 7,2000 General what is the best way to search between tow date fd RE: what is the best way to search between tow date fd

  • In English, not SQL, what are you trying to accomplish here? Have you taken a look at DATEADD(hour, DateField)? To strip the time portion of a datetime field, use DATEADD(day, 0, DATEDIFF(day, 0, DateField)) since it requires no lookup to syslanguages to find the localization string for CONVERT(varchar, DateField, 112). Also, use the BETWEEN clause. Demonstrated techniques below...:

    
    
    WHERE
    --...statements here...
    AND
    (
    dbo.mainb.tarihb BETWEEN
    DATEADD(hour, 1, DATEADD(day, 0, DATEDIFF(day, 0, GETDATE())))
    AND
    DATEADD(hour, -1, DATEADD(day, 31, DATEADD(day, 0, DATEDIFF(day, 0, GETDATE()))))
    OR
    --...convert the rest like above...