473,545 Members | 2,013 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Date Stored Procedure

Hi all,

I am trying to write a stored procedure that will delete records in a
table that are older then 30 days. I am checking against a field that
is called PositionDate. Can someone point me in the right direction?

TIA
Jul 20 '05 #1
4 2576
DELETE
FROM Sometable
WHERE positiondate < DATEADD(D,-30,CURRENT_TIME STAMP)

--
David Portas
------------
Please reply only to the newsgroup
--
Jul 20 '05 #2
Thanks that works great. My next newbie question is, is there a way to
have the SQL server run this automatically once a day?

On Mon, 8 Dec 2003 21:04:46 -0000, "David Portas"
<RE************ *************** *@acm.org> wrote:
DELETE
FROM Sometable
WHERE positiondate < DATEADD(D,-30,CURRENT_TIME STAMP)

--
David Portas
------------
Please reply only to the newsgroup


Jul 20 '05 #3
Yes, you can create and schedule a job:

http://msdn.microsoft.com/library/en...omate_42r7.asp

--
David Portas
------------
Please reply only to the newsgroup
--
Jul 20 '05 #4
Thanks for the link. It was very helpful!

On Mon, 8 Dec 2003 22:17:00 -0000, "David Portas"
<RE************ *************** *@acm.org> wrote:
Yes, you can create and schedule a job:

http://msdn.microsoft.com/library/en...omate_42r7.asp

--
David Portas
------------
Please reply only to the newsgroup


Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
10252
by: Robin Lawrie | last post by:
Hi again, another problem! I've moved from an Access database to SQL server and am now having trouble inserting dates and times into seperate fields. I'm using ASP and the code below to get the date and time, but my script is erroring. '-- Get login date and time cmdLoginDate = Date() cmdLoginTime = Time()
7
32929
by: Marc Pelletier | last post by:
Hello, I have a table with a Day field, defined as smalldatetime. I am filling it from a CSharp application with the following code: DataRow r = dtStaDays.NewRow(); r= station_ID; r = sd.Date; r = rangeTide; etc.
8
3250
by: JIM.H. | last post by:
Hello, I am calling a stored procedure to update my table. If one of the date on the screen left empty, I need to send date as null. Since MyDate=”” gives error in asp.net, how should I do this? Thanks, Jim.
8
3617
by: John Wildes | last post by:
Hello all I'm going to try and be brief with my question, please tell me if I have the wrong group. We are querying transaction data from a DB3 database application. The dates are stored as text fields. Each date for example 10/31/03 or October 31st 2003 is stored as 10/31/A3 in the system. My reasoning for this is because they...
5
3045
by: yvind Isaksen | last post by:
I have a page with an optional integer-field, and one asp:calendar control. I use a stored procedure to save the data in SQL Server. When all fields contains data, the code works great! But if the user dont fill in the optional "price-field" (integer value), or if the user dont choose a date in the asp:calendar control, I get the message...
2
11491
by: syntego | last post by:
We commonly use triggers to log changes to our main tables to historical log tables. In the trigger, we create a concatenated string of the old values by casting them as follows: CAST(O.MYDATE AS CHAR(30)) When directly updating date fields in the main table, the logged value gets saved in the format YYYY-MM-DD as expected.
1
1798
by: gderosa | last post by:
Hey everyone...I need to create a job which occurs once monthly that is based on a stored procedure that contains as a rough example: CREATE PROCEDURE CompareDate @CurrentDate datetime AS SELECT * FROM Contracts WHERE EndDate LIKE (CURRENT SERVER DATE) GO
2
2814
by: Brad Pears | last post by:
I am working on a vb.net 2005 project using sql server 2000 as the backend . I am having a bit of problems with date variables... Here is the scenario... I have a table that includes a couple "smalldatetime" fields. In my class for this table, when inserting new or saving a row in the table, both of these date values may possibly be...
4
2845
by: oracle newbie | last post by:
create or replace PROCEDURE LIBHOME(ldt zen.logdatetime%TYPE) IS lv_count NUMBER; BEGIN SELECT COUNT(*) INTO lv_count FROM zen WHERE TRUNC(logdatetime) = TRUNC(sysdate); IF lv_count > 0 THEN
4
8300
Soniad
by: Soniad | last post by:
Hello, I am passing date and time individually to stored procedure as parameters as follows : Exec mySP '01/31/2009' , '5:03:56 PM' whithin this stored procedure, i have declared one variable (senddatetime varchar(50)) , i want to concat this date & time and want the date format value as 01/31/2009 5:03:56 PM
0
7473
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main...
0
7406
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
1
7431
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7761
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5337
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 presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4949
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1020
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
709
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.