Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM SQL » View Thread |
Messages 1 to 9 of 9 total |
Sql to delete records older then x minutes |
Sun, Feb 5 2006 11:40 PM | Permanent 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 AM | Permanent Link |
Steve Forbes Team Elevate | Hi Bern,
>I must be having a major brain fart. I love that expression! How are you? Long time no hear 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 AM | Permanent 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 AM | Permanent 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 AM | Permanent 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 PM | Permanent 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 PM | Permanent Link |
Steve Forbes 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 AM | Permanent 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 AM | Permanent 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 -- |
This web page was last updated on Tuesday, April 30, 2024 at 03:55 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |