• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Date diff issue

New Here ,
Oct 14, 2007 Oct 14, 2007

Copy link to clipboard

Copied

Hi i have a delete function using MS SQL.

DELETE FROM TABLE
WHERE DATEDIFF(d, InDate, GETDATE()) >= 28

this should delete any entries that are 28 days old, but "InDate" is a datetime stamp and the delete fuction is actually deleting rows that i enter taday.

any ideas why?
TOPICS
Advanced techniques

Views

228

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Oct 14, 2007 Oct 14, 2007

Copy link to clipboard

Copied

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guide ,
Oct 14, 2007 Oct 14, 2007

Copy link to clipboard

Copied

LATEST
> this should delete any entries that are 28 days old

28 days or older, from the date and time now.

> WHERE DATEDIFF(d, InDate, GETDATE()) >= 28
> any ideas why?

I don't see how that's possible unless perhaps InDate is not a datetime column or the value in the InDate column is not what you think it is.


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation