Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 9 of 9 total
Thread Sql to delete records older then x minutes
Sun, Feb 5 2006 11:40 PMPermanent Link

"Bern Rudisill"
I must be having a major brain fart.

If I have a column named DateTimeAdded that is a timestamp, what would
be the sql to delete all rows older then x minutes


would it be something line
DELETE From Table where CURRENT_TIMESTAMP-DateTimeAdded>X Minutes?

minutes could be anything i.e. 30 minutes or even 3456 minutes (2.5
days)

Thanks
Bern


--
Mon, Feb 6 2006 12:28 AMPermanent Link

Steve Forbes

Team Elevate Team Elevate

Hi Bern,

>I must be having a major brain fart.

I love that expression!

How are you? Long time no hear Wink

DBISAM stores date/time values in milliseconds, .. you can use the MSEC
related functions in your SQL statements

e.g. the following should do what you want.

DELETE From Table where MINSFROMMSECS(CURRENT_TIMESTAMP-DateTimeAdded) > X

Best regards

Steve

"Bern Rudisill" <bernr@no-sp.am.exitcare dot com> wrote in message
news:91028386-D719-43BE-B065-1927F9739A0B@news.elevatesoft.com...
>I must be having a major brain fart.
>
> If I have a column named DateTimeAdded that is a timestamp, what would
> be the sql to delete all rows older then x minutes
>
>
> would it be something line
> DELETE From Table where CURRENT_TIMESTAMP-DateTimeAdded>X Minutes?
>
> minutes could be anything i.e. 30 minutes or even 3456 minutes (2.5
> days)
>
> Thanks
> Bern
>
>
> --
>

Mon, Feb 6 2006 6:58 AMPermanent Link

"Bern Rudisill"
Steve Forbes wrote:

> MINSFROMMSECS(CURRENT_TIMESTAMP-DateTimeAdded) > X

Thanks Steve, works like a charm.

Yea I seem to be having a lot of "brain farts" lately as my mind has
been turned to mush as I have been tracking down an AV error in a
thread for the last month.

Bern

--
Mon, Feb 6 2006 9:35 AMPermanent Link

"Frans van Daalen"

"Bern Rudisill" <bernr@no-sp.am.exitcare dot com> wrote in message
news:F1B87A40-4B1A-46C8-9E26-9BAB0FB0C941@news.elevatesoft.com...
> Steve Forbes wrote:
>
>> MINSFROMMSECS(CURRENT_TIMESTAMP-DateTimeAdded) > X
>
> Thanks Steve, works like a charm.
>
> Yea I seem to be having a lot of "brain farts" lately as my mind has
> been turned to mush as I have been tracking down an AV error in a
> thread for the last month.
>
> Bern
>
> --
OT : Ever tried Madshi's Madexcept together with FastMM? This combo helped
me in solving some thread issues I (used to) have.

Mon, Feb 6 2006 11:48 AMPermanent Link

"Bern Rudisill"
I actually use both; the problem was the AV kept jumping around. I
finally tracked it down that Delphi was freeing my Data Module before
thread was finished. I was using a JVThread component that was not
terminating with it was told to. I fixed this by just ripping out the
thread and writing a supporting program that runs parallel with the
main program. This fixed the AV and it also sped up the entire process.

Bern

--
Mon, Feb 6 2006 1:59 PMPermanent Link

"Bern Rudisill"
Bern Rudisill wrote:

> Steve Forbes wrote:
>
> > MINSFROMMSECS(CURRENT_TIMESTAMP-DateTimeAdded) > X
>
> Thanks Steve, works like a charm.
>
> Yea I seem to be having a lot of "brain farts" lately as my mind has
> been turned to mush as I have been tracking down an AV error in a
> thread for the last month.
>
> Bern

Acutally this does not work for me and here is why, this function Takes
milliseconds and returns the number of minutes (as a remainder of the
above years, days, and hours, not as an absolute).

so If I say

Delete from table where MINSFROMMSECS(CURRENT_TIMESTAMP-DateTimeAdded)
> 63

nothing would ever get deleted.

Bern


--
Mon, Feb 6 2006 3:10 PMPermanent Link

Steve Forbes

Team Elevate Team Elevate

Hi Bern,

You could do it "longhand" then ..

Delete from table where (CURRENT_TIMESTAMP-DateTimeAdded) > (X * 60 *
86400000)

HTH
--
Best regards

Steve

"Bern Rudisill" <bernr@no-sp.am.exitcare dot com> wrote in message
news:79CD6FC0-A15E-4A69-9A11-FDF5EE4CD129@news.elevatesoft.com...
> Bern Rudisill wrote:
>
>> Steve Forbes wrote:
>>
>> > MINSFROMMSECS(CURRENT_TIMESTAMP-DateTimeAdded) > X
>>
>> Thanks Steve, works like a charm.
>>
>> Yea I seem to be having a lot of "brain farts" lately as my mind has
>> been turned to mush as I have been tracking down an AV error in a
>> thread for the last month.
>>
>> Bern
>
> Acutally this does not work for me and here is why, this function Takes
> milliseconds and returns the number of minutes (as a remainder of the
> above years, days, and hours, not as an absolute).
>
> so If I say
>
> Delete from table where MINSFROMMSECS(CURRENT_TIMESTAMP-DateTimeAdded)
>> 63
>
> nothing would ever get deleted.
>
> Bern
>
>
> --
>

Sat, Feb 18 2006 10:52 AMPermanent Link

"Bern Rudisill"
Steve Forbes wrote:

> Hi Bern,
>
> You could do it "longhand" then ..
>
> Delete from table where (CURRENT_TIMESTAMP-DateTimeAdded) > (X * 60 *
> 86400000)
>
> HTH
Shouldn't this be

Delete from table where (CURRENT_TIMESTAMP-DateTimeAdded) > (X * 60  *
60000)

where x is the # of minutes, since there are 60000 milliseconds in a
minute?

Bern
--
Sat, Feb 18 2006 11:40 AMPermanent Link

"Bern Rudisill"
Bern Rudisill wrote:

> Steve Forbes wrote:
>
> > Hi Bern,
> >
> > You could do it "longhand" then ..
> >
> > Delete from table where (CURRENT_TIMESTAMP-DateTimeAdded) > (X * 60
> > * 86400000)
> >
> > HTH
> Shouldn't this be
>
>  Delete from table where (CURRENT_TIMESTAMP-DateTimeAdded) > (X * 60
> * 60000)
>
> where x is the # of minutes, since there are 60000 milliseconds in a
> minute?
>
> Bern

Edited message I had an extra number in the equation

Shouldn't this be

 Delete from table where (CURRENT_TIMESTAMP-DateTimeAdded) > (X *
60000)

where x is the # of minutes, since there are 60000 milliseconds in a
minute?

Bern

--
Image