473,498 Members | 1,992 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

truncating data older than 30 days

8 New Member
Hi,

I have a table with
C1- ID
C2-Date
C3-Date with time
C4-quantity

I need to create a daily process that will remove the oldest data(data older than 30 days) on the table and make sure the table is with only 30 days worth of data.


Please help me.

Thanks in advance
Dec 14 '07 #1
1 5530
ck9663
2,878 Recognized Expert Specialist
Hi,

I have a table with
C1- ID
C2-Date
C3-Date with time
C4-quantity

I need to create a daily process that will remove the oldest data(data older than 30 days) on the table and make sure the table is with only 30 days worth of data.


Please help me.

Thanks in advance
based on which datecolumn?


assuming c2
DELETE FROM myTable where datediff(day,c2, getdate()) > 30

couple of notes:
1. you might not be able to recover these records.
2. you may add a column to flag if the record is valid or not and just use that instead.
3. backup this table, and delete the records.

-- CK
Dec 14 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
2936
by: Frnak McKenney | last post by:
Back when computer dinosaurs roamed the earth and the precursors to today's Internet were tiny flocks of TDMs living symbiotically with the silicon giants, tracking access to data processing...
6
1996
by: Conrad | last post by:
Greetings, In short: Using a new FreeBSD (4.9) PostgreSQL (7.3) server, can I rescue PostgreSQL data from a hard drive pulled from an older (motherboard just died) FreeBSD (4.??) PostgreSQL...
4
4438
by: rajdb2 | last post by:
Hi, I am using the following sql statement SELECT rtrim(rtrim(coalesce(substr(char(v.creationdate),1,4) || '-' || substr(char(v.creationdate),6,2) || '-' || substr(char(v.creationdate),9,2) ||...
4
11846
by: Shyguy | last post by:
I have a database that backs up critical tables to a database, named Backup with the date, daily. I can't figure out how to delete these databases programmatically, say when they are 5 days old or...
5
5413
by: VISHNU VARDHAN REDDY UNDYALA | last post by:
Hello, Can someone over here help me in truncating a float variable. I mean if PI=3.14159 ...How can I get to read the first two or first three decimal values with out rounding them. Any...
3
1690
by: Titan | last post by:
When I run my project (F5), it runs an older version of my project. However, when I build or rebuild the solution, it builds flawlessly... so shouldn't this overwrite the older version of my...
2
2812
by: DThreadgill | last post by:
I am pulling data into Access directly from a SQL Server (ODBC Connection). The properties of the field in question is set to memo. I'm making a query and joining to another stand-alone table in...
3
5431
by: jaeden99 | last post by:
I was wandering if nyone has a script to move files older than x days old? i've seen several to delete, but I don't want to delete. I would like to create a backup of the files first verify with...
2
24076
by: Thomas Bauer | last post by:
Hello, Call DeleteFiles bgW_DeleteFilesProcess = new DeleteFiles(); bgW_DeleteFilesProcess.RunAsync( folder, 5, "*.txt", new RunWorkerCompletedEventHandler( RunWorkerCompleted_DeleteFiles_TXT )...
0
7379
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5462
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4908
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4588
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3081
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1417
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
656
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
290
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.