Solved

Delete Records After 24H

Posted on 2011-03-22
3
503 Views
Last Modified: 2012-05-11
Hello Experts,

I have a MSSQL 2008 DB, with a varchar field that has a value like 3/21/2011 1:19:33 PM On this field i'm also able to use convert(datetime, fldPostedDateTime, 101).

My question is, with this info, how can i add a WHERE clause to check if 24 hours have past?

Thanks.
0
Comment
Question by:APD_Toronto
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 60

Assisted Solution

by:chapmandew
chapmandew earned 250 total points
ID: 35192235
delete t
from tablename t
where datefield < dateadd(hour, -24, getdate())
0
 
LVL 11

Accepted Solution

by:
Larissa T earned 250 total points
ID: 35194805

run select first just to be safe :-)
delete t
--select *
from tablename t
where convert(datetime, fldPostedDateTime)< dateadd(hour, -24, getdate())
0
 

Author Closing Comment

by:APD_Toronto
ID: 35195310
thanks both
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
I have a large data set and a SSIS package. How can I load this file in multi threading?
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question