Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!
  1.   Become a Supporter    ::   Make a Contribution   
    Target (Recurring Monthly): $200 :: Achieved: $98

Deleting Records based on a certain amount of time

Discussion in 'Information Technology' started by Jason, Nov 3, 2005.

  1. Jason

    Jason
    Expand Collapse
    Guest

    Is this possible, Say I have users that enter information and it is saved by
    radio day. is there a way to query the database table (that contains the
    information) and have it reference the current date and automatically delete
    the day if it is over 6 months old?
     
  2. Loading...


  3. Brendan Reynolds

    Brendan Reynolds
    Expand Collapse
    Guest

    DELETE *
    FROM tblTest
    WHERE (((DateDiff("m",[RadioDay],Date()))>=6));

    In query design view, it looks like this ...

    Field: DateDiff("m",[RadioDay],Date())
    Criteria: >=6

    --
    Brendan Reynolds

    "Jason" <Jason@discussions.microsoft.com> wrote in message
    news:D23C2A73-79C6-4395-9048-F65051D0DA10@microsoft.com...
    > Is this possible, Say I have users that enter information and it is saved
    > by
    > radio day. is there a way to query the database table (that contains the
    > information) and have it reference the current date and automatically
    > delete
    > the day if it is over 6 months old?
     
  4. Ofer

    Ofer
    Expand Collapse
    Guest

    First, please back up.

    You can use the DateAdd together with date() that return the current date,
    in the criteria of a delete query

    DELETE TableName.*
    FROM TableName
    WHERE TableName.DateField>DateAdd("m",6,Date())

    --
    If I answered your question, please mark it as an answer. That way, it will
    stay saved for a longer time, so other can benefit from it.

    Good luck



    "Jason" wrote:

    > Is this possible, Say I have users that enter information and it is saved by
    > radio day. is there a way to query the database table (that contains the
    > information) and have it reference the current date and automatically delete
    > the day if it is over 6 months old?
     
  5. Ofer

    Ofer
    Expand Collapse
    Guest

    Sorry, I ment

    DELETE TableName.*
    FROM TableName
    WHERE TableName.DateField>DateAdd("m",-6,Date())

    --
    If I answered your question, please mark it as an answer. That way, it will
    stay saved for a longer time, so other can benefit from it.

    Good luck



    "Ofer" wrote:

    > First, please back up.
    >
    > You can use the DateAdd together with date() that return the current date,
    > in the criteria of a delete query
    >
    > DELETE TableName.*
    > FROM TableName
    > WHERE TableName.DateField>DateAdd("m",6,Date())
    >
    > --
    > If I answered your question, please mark it as an answer. That way, it will
    > stay saved for a longer time, so other can benefit from it.
    >
    > Good luck
    >
    >
    >
    > "Jason" wrote:
    >
    > > Is this possible, Say I have users that enter information and it is saved by
    > > radio day. is there a way to query the database table (that contains the
    > > information) and have it reference the current date and automatically delete
    > > the day if it is over 6 months old?
     
Since you're here... we have a small favor to ask...

More people are visiting & reading SPN than ever but far fewer are paying to sustain it. Advertising revenues across the online media have fallen fast. So you can see why we need to ask for your help. Donating to SPN's is vote for free speech, for diversity of opinions, for the right of the people to stand up to religious bigotry. Without any affiliation to any organization, this constant struggle takes a lot of hard work to sustain as we entirely depend on the contributions of our esteemed writers/readers. We do it because we believe our perspective matters – because it might well be your perspective, too... Fund our efforts and together we can keep the world informed about the real Sikh Sikhi Sikhism. If everyone who writes or reads our content, who likes it, helps us to pay for it, our future would be much more secure. Every Contribution Matters, Contribute Generously!

    Become a Supporter      ::     Make a Contribution     



Share This Page