Delete Records Using A Date Field

I've got a table with three fields:

ref (Autonumber)
notice (memo)
expdt (Date)

I'm trying to use an SQL statement to delete all records where expdt < the current date (Now). Here is the code I'm using:

<%
If Request.Querystring("act") = "clean" Then

Set conn = Server.CreateObject("ADODB.Connection")
conn.Open ConnStr

strExpdt = cdate(Now())

sql = "DELETE FROM tblNboard WHERE expdt < " & Now()

conn.Execute sql

conn.close
set conn = nothing

strResponse = "All expired notices have successfully been deleted."

End If
%>

However, this just gives me the following error:

Syntax error (missing operator) in query expression 'expdt < 11/12/2003 19:54:25'.

What am I doing wrong??

View Replies


ADVERTISEMENT

Delete ALL Records Before Current Date

how can you delete every single record in a table from the access DB with a DATE column, which stores the date in format DD/MM/YYYY? Code:

View Replies View Related

Delete Records

i put a message box and asked the user if they are sure they wana deletethe record. if no,it will cancel the work.

if yes, it will delete the last record no matter which record you choose. i see where the problem is because the code come in a loop and so the last value of that loop will be the last one. i need to know if there is a way to solve this so that it will take the value of the chosen record?

View Replies View Related

Add Records Before Delete

This code works great--but only the first time. Once the HoldingTable1 is created, I can't get the SQL to append records. Anybody have any ideas how to tweak this into an INSERT INTO statement that works?

strSQL = "select * into HoldingTable1 from " & strTableName & " where " & AddWrappers(strKeyField) & "=" & gstrQuote & Replace(request.form("mdelete1")(ind), "'", "''") & gstrQuote
dbConnection.Execute strSQL

dbConnection.Execute strSQL
strSQL="Delete from " & strTableName & _
" where " & AddWrappers(strKeyField) & "=" & gstrQuote & Replace(request.form("mdelete1")(ind), "'", "''") & gstrQuote

View Replies View Related

Delete Records

I created a form that will update or delete a record using ASP and FrontPage 2002. This worked fine until I loaded the .Net framework 1.1 on my Win 2K server. Now when a user tries to delete a record or perform an update of a record the following error is given.

Your page contains a query with user input parameters that could not be resolved. This could happen if your DatabaseRegionStart webbot has an empty or missing s-columnnames or s-columntypes attributes. You may need to read Microsoft Knowledge Base Article 817029. This article only refers to how to fix the problem in FrontPage 2003. What do we do to fix the error for those of us who have not updated to FP 2003?

View Replies View Related

Delete Multiple Records

I read this article below and play around with delete multiple records function in dreamweaver. Assume that all my database fields setup are exactly like the code below. I was able to follow the instruction and did everything excepted line# 29. Can someone give me a suggestion of the line# 29 suppose to be (in example if possible).....

View Replies View Related

How Do I Delete Records From My ASP Page?

At the load of an ASP page I would like to delete all records in my MDB that have the value of 'gmp@gmail.com' in the 'email' field. How would I do this using VB? Here is the code I have: Code:

View Replies View Related

LEFT JOIN On A Date Field And A Numerical Field - Using WHERE Clause

I am using a Relational database for my site and i have the following tables:

FIXTURES, GAMEDATES

the fields in FIXTURES are:

GameDate
Home
Away

(All of the above are numerical fields)

the fields in GAMEDATES are:

DateID(integer)
GameDate(#Date Field#)

What i have done is in the GAMEDATE field in the FIXTURES table i have used the ID number of the date that i wish to assign to that record - using a LEFT JOIN to display the actual date that is pulled from the GAMEDATES table (That which corresponds to the relevant id used in Fixtures)

The problem is that in some of my code i want to display records using sql and sometimes in the where clause i use the following:

WHERE Fixtures.GameDate<=(Date())

obviously meaning WHERE GAMEDATE is LESS THAN or EQUAL to TODAY.

The thing is when i use the join it does not use the where clause and displays all of the records in the FIXTURES table.

Does any one know how to get around this, i have not received any error messages it just isnt displaying the right data

View Replies View Related

Delete A Number Field

Using ASP, how would I make a field in an entry 'blank', baring in mind that its a number field. I have tried...

RS.Field("ReviewID") = ""
and
RS.Field("ReviewID") = vbnull

But it doesnt like either of them.

View Replies View Related

How To Delete Multiple Records Using A Series Of Checkboxes

Does anyone know how i could print multiple records in a database using a series of check boxes on a webpage? i.e it prints all the records that have been ticked?

View Replies View Related

Select Statement Comparing Date() & Date Field Of Database

i'm new here and i'd like to ask if there's someone who knows how to compare date() function and date from database with date/time type inside select statement so i don't have to do if..then..else

View Replies View Related

ASP Date: Get Records With Date = Today (SQL Server)

I'm trying to get all records from my SQL Server Database with
"DeadlineDate" = today (not today - 24 hours).

All records has a field called "DeadlineDate", and the date is stored in
this field like this: 13.08.2005 07:00:00

I dont care about the hours (Ex: 07:00:00), just the date (ex: 13.08.2005).
This is the SQL I have made, it gets all the record with the date = today -
24 hours... but that is not what I want.

sql = "select title from tblProject where (deadlineDate BETWEEN DATEADD(d, -
1, GETDATE()) AND GETDATE())"

How can I get just the records that has the date = today's date??

View Replies View Related

MS SQL Database Field Date Comparison To Date()

In a connection string, I have the following:

sql3 = "SELECT DISTINCT State FROM Property Where TypeID = '" & srch_cat & "'"

In the database, is a field called expiredDate I am trying to show only records whose expiredDates are greater than todays date, but I am messing up somewhere. The values in the fields are as this: 3/7/03 (or something like that...no time is added to it)

View Replies View Related

Comparing A Date Field To A Date In A Form.

"SELECT id, title FROM Businesses WHERE Date_Added >= " &
Request.Form("Since_Date")

This SQL string returns all records from the table Businesses and does
not seem to be able to recognise Request.Form("Since_Date") as a valid
date. The Since_Date value is entered into a form field as
"01-Jan-2005" and appears to be treated as a date; when viewing the
SQL statement(with a response.write) it shows the date as 1/1/2005
even if it is entered into the form as 2005/1/1

I've also tried CDate(Request.Form("Since_Date")) with no luck,
although this was the treatment that worked when the SQL statement was
running in an .idc file.

Date_Added is a regular DateTime field in an Access 2000 database

Any suggestions please ?????

View Replies View Related

Update A Field For A Bunch Of Records At Once?

My products table has a weight field that I need to populate. A bunch of them have it and a bunch of them don't, but I need them all to have one. The weight is the same, 3, for all the records. I also have an Include field in that table. I want to make the weight field 3 for all records where the include field is true (it's a yes/no checkbox in access.)

I'm using Dreamweaver and I can build the SQL statement just fine but I'm not sure of how to loop through this to set the field for each of these records.

View Replies View Related

Adding Records With Autonumber Field

I'm writing a database admin page in ASP. I had it adding records correctly. Then I added an autonumber field ("ID") to the table, and it stopped working. The sql I'm using is Code:

View Replies View Related

How Do Find A Empty Field/value/records?

I know it should be very easy but I am new in ASP so I could not figured out.
Here is the simplified version of my code:

thePaymentID= request.querystring("IDValue")

SQLqueryPayment= "SELECT sum(paid) as paid, sum(Interest) as interest
FROM payment WHERE payment_ID =" & thePaymentID & ""

dim rstempPayment
set conntemp=server.createobject("adodb.connection")
conntemp.Open "DSN=payment"

set rstempPayment=conntemp.execute(SQLqueryPayment)

fldValPaid = rstempOwner.Fields("paid").Value
------------------------------------------------------------------------

I need to find out if "fldValPaid" hold anything. I will use it an IF ELSE statement. In payment table a particular record could exist or not. How do I find out by evaluating "fldValPaid" if any record exists or not. I have to find out using "fldValPaid" ...I can not use number of record/record return or any other method.

View Replies View Related

Save Db Records Of A Field In An Array

I want to save db records of dates in an array something like the below(I know it's wrong, i'm just trying to describe what I want)... Code:

View Replies View Related

Stuck On Update Multiple Records (same Field)

how to update a database from a dynamic table with checkbox. Their is only one field I would like to change and that is the one with the checkbox.

I am using Dreamweaver and I create a dynamic table, add the update record and I get BOF EOF error. The database does have data in it. Code:

View Replies View Related

Returning Records Based On Time Field

How does one return records in a recordset based on a time/date field. If todays date is 8/25/04, how could i return all those records from 8/25/04. Mind you, i have long date format ex. "8/25/2004 4:46:45 pm"

I dont want to user a form for this i simply just want these time- sensative records to be returned in the recordset .

View Replies View Related

Get Records With A Date

I am trying to get only the records that have a date entered. my select statment;

strQ ="SELECT Inquiries.CustomerID AS CustomerID, Inquiries.CustomerFName AS CustFName, Inquiries.CustomerLName AS CustLName, Inquiries.CustomerSSN AS CustSSN, Inquiries.CustomerDriverLicense AS CustDrLic, Inquiries.KnownWaterCo AS KnownWaterCo, Inquiries.ShutOffDate AS ShutOFF FROM Inquiries WHERE ((Inquiries.InquiringWaterCo='"&WaterCo&"') AND (Inquiries.Shutoff<>'' ));"

View Replies View Related

Displaying Records By Date From To

I want to be able to display records inputed from Monday at 12:00am to Sunday at 5 pm. Every week.

So far, I can display records for the last 7 days, but How can I be more specific?

Any Ideas??

View Replies View Related

Fetch Records Within Due Date

I need to run a query to get records with date within 30 days from current date.What I used to do with SQL server 2000 was the following:

Date30More = Date+30
MPQry = "SELECT * FROM SOP_T where Rev_Date < '" & Date30More

This stops working with Oracle because Rev_Date in Oracle is in the format of "DD-MON-YYYY HH:MM:SS PM". Therefore, I received an error message as the following:
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80004005)
[Oracle][ODBC][Ora]ORA-01858: a non-numeric character was found where a numeric was expected

View Replies View Related

Selecting Records Where Date Between Two Dates

I'm trying to display all the jobs that occur during a selected month/s. Here is the code I use: Code:

View Replies View Related

Sort Records By Short Date,

I like to pull the top 5 record that are closest to the current date but the date field can not be empty, see some records do not get assigned an expire date and others do. I want to show the closest expiring records.

objconn.commandtext = "SELECT TOP 5 * FROM merchants ORDER BY Expires"

What do I need to add to exclude the emtpy expires field records.

View Replies View Related

Query All Records After Today's Date

I've got an access database with a field containing dates (each saturday of the year), set up as a date field. In my code i need to write the SQL to select all records that have a date after todays date.

I've got the rest of the code but it's the where clause i'm stuck on. Something like, WHERE mydatefield is after (could i use >?) currentdate. Not really sure how ot go about doing this... I'm using ASP, is there a way the SQL can get the current date, or would i need to generate it and store as a variable first? Also, don't know what type of quotes i would need to use " or ' or + etc.

View Replies View Related

Duplicate Records With A Date Block

I am looking to create a calendar. I am stuck on how duplicate records based in a date parameter. Example

A person is off between 12-01-04 to 12-09-04 . They submitted a form than contains the description. I want the record to duplicate 8 times because of the date paremeter.

View Replies View Related

Can't Display Today's Date Records With = Now()

I'm trying to display only those records from the events table with today's date in the event_date field. I thought it would be easy to do with

"SELECT * FROM events where event_date = now() order by event_date asc"

But that returns nothing at all. why it won't work?

View Replies View Related

Retrieving Date Field

I am trying to retrieve a date field this is the code

strQ ="SELECT * FROM WaterCompanies ORDER BY WaterCompany"

set objRS=objConn.Execute(strQ)

This is where I am using the date

Response.Write "<TD>"

Reponse.Write objRS("JoinDate")

Response.Write "</TD></TR>"

all the other fields populate so I know I have a good connection.

this is the error



Microsoft VBScript runtime error '800a01a8'

Object required: '' /waterbilling.asp, line 76 <--- this is the response.write objRS("JoinDate") line

View Replies View Related

Format Date Field

i need help formating todays date minus one.
i can get this 1212006 but i need 12012006

View Replies View Related

How To Prepopulate Date Field In Asp With Sql

how to pre populate the date field in an asp form which is using SQL database?

View Replies View Related

Time/Date Field

I have a few date fields on my form. The backend is SQL and the fields are set to smalldatetime. Adding records into these fields is not a problem. This is my code:

if Request.form("ScheduledTrainingDates") = "" then
else
objRS("ScheduledTrainingDates")=Request.form("ScheduledTrainingDates")
end if

The problem is updating the records when I got to edit them. Let's say I have a value in for ScheduledTrainingDates textbox, and I want to clear the value and leave it blank and save it to the database. How do I do this?

View Replies View Related

Validating A Date Field

I have a form field which asks for a date to be entered in the format of dd/mm/yyyy. Now, I've successfully programmed it so that you can only enter a date in the present or future but not in the past. However, as it stands, it also means the user could enter an unrealistic date such as 12/12/2070...I don't want this.

What I'm after is some ASP code which only allows the user to enter a date that occurs between the present day and say, the next month. So if the user was to enter 05/03/06 then the valid dates that would be acceptable would be any date before 05/04/06 i.e. One month.

View Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved