Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Need help fast!!

Posted on 1998-10-06
5
Medium Priority
?
246 Views
Last Modified: 2010-03-19
I want to delete items in an SQL-database.
At the moment I use the statement:

rensaStr="DELETE from IntranetUser.aktiviteter WHERE datum < '" &DateValue(DateSerial(year(date()),month(date()),day(date())-1))&" "&Time()&"'"
Set rensaoRs = Conn.Execute(rensaStr)

The field "datum" is a date field. What I want to do is to only remove entries which date is passed, not the time. I mean, if the date is set to 4 of july 10 am I want it to be removed as soon as it is the 5:th of july. Not at 10 am the 5:th. Is this possible without extracting, iow just using the delete sentence?
0
Comment
Question by:EasyQ
[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
  • 2
5 Comments
 

Author Comment

by:EasyQ
ID: 1090400
Edited text of question
0
 
LVL 7

Accepted Solution

by:
Victor Spiridonov earned 100 total points
ID: 1090401
Delete  from table where convert(varchar(10),datum,103)<"05/10/1998"
0
 

Author Comment

by:EasyQ
ID: 1090402
I tried this:

Delete  from table where convert(varchar(10),datum,103)<'"&DateValue(DateSerial(year(date()),month(date()),day(date())-1))&" "&Time()&"'"

It erased all entries before 23 october. So I don't really like what you did... btw what does the convert(varchar(10),datum,103) really do?

The datum fields data is store like this "10/11/12 11:12 AM"

0
 
LVL 7

Expert Comment

by:Victor Spiridonov
ID: 1090403
Convert function converts datetime to varchar datatype,representing only date part.
> if the date is set to 4 of july 10 am I want it to be
>   removed as soon as it is the 5:th of july.
If it is so ,why are you adding time portion in your statement ?
>"&Time()&"'"
 
0
 

Author Comment

by:EasyQ
ID: 1090404
I ad it since the value in the database is stored with the time too. (need to be stored that way) but now that I understand what the convert does, I understand that I shouldn't use the &"time()&"
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam® is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

Question has a verified solution.

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

For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.

610 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