Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 17th, 2003, 04:03 AM
Registered User
 
Join Date: Jul 2003
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Urgent help needed! Compare a string to Sysdate in

I am trying to write a simple SQL statement which will take a string
(startdate) in the format DDMMYYYY and compare it to a date stored in
an Oracle database. My SQL is as follows:

<%

"select * from tblhistory where datechanged = '" & startdate & "'"

%>

The field datechanged in the Oracle database is set up using the
Sysdate variable, on a previous occasion.

Any ideas how I can get my startdate variable into the correct format
so that I can compare it with the 'datechanged' field?

Thanks in advance.


 
Old July 17th, 2003, 06:11 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: Sydney, NSW, Australia.
Posts: 215
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Everybody's question is urgent to them.

Try using an ANSI date format, eg yyyy-mm-dd. Assuming that your date is always in for format DDMMYYYY (and not DMMYYYY or DDMMYYYY) then try the following:

Code:
<%
startdate = Left(startdate, 2) & "-" & Right(Left(startdate, 4), 2) & "-" & Right(startdate, 4)

SQL = "SELECT * FORM tblhistory WHERE datechanged = '" & startdate & "'"
%>
I don't know oracle, but you may find that sysdate also stores a time as well as a date, in wich case you may have problems with this query. I'd suggest doing some testing of your SQL statement in whatever client tools oracle offers you.

regards
David Cameron




Similar Threads
Thread Thread Starter Forum Replies Last Post
A serious string problem. Urgent solution needed. asfak XSLT 2 November 28th, 2007 06:08 AM
Needed Very Urgent ndrnathan C# 0 June 8th, 2007 07:43 AM
string compare in table field alxtech SQL Server 2000 1 April 27th, 2007 12:25 AM
Urgent help! Compare a string to Sysdate in Oracle WroteForLuck Classic ASP Basics 1 July 22nd, 2003 01:48 AM
How to compare a string with the & sign in it? apd8x Javascript 3 June 13th, 2003 02:25 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.