CodeCharge Studio
search Register Login  

Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> ASP

 Problem comparing dates

Print topic Send  topic

Author Message
dhodgdon

Posts: 80
Posted: 04/26/2005, 8:35 PM

I am successful comparing Text Boxes of Data Type Date when I use the XXX.value run-time properties. For example If XXX.Value > YYY.Value then...

I am inconsistently successful comparing Text Boxes of Data Type Date XXX.Value run-time properties against constants. For example If XXX.Value > "6/9/2005" then...

What is the proper way to compare a Text Box of Data Type Date XXX.Value run-time property against a constant?

Is it dependent on the format chosen for dates?
_________________
Regards,
David Hodgdon
View profile  Send private message
DonB
Posted: 04/26/2005, 8:52 PM

You might get by using Clng() on each value to convert them to their numeric
date representations as Long Integers. Then compare those.

--
DonB

http://www.gotodon.com/ccbth


"dhodgdon" <dhodgdon@forum.codecharge> wrote in message
news:6426f089b3a96a@news.codecharge.com...
> I am successful comparing Text Boxes of Data Type Date when I use the
XXX.value
> run-time properties. For example If XXX.Value > YYY.Value then...
>
> I am inconsistently successful comparing Text Boxes of Data Type Date
XXX.Value
> run-time properties against constants. For example If XXX.Value >
"6/9/2005"
> then...
>
> What is the proper way to compare a Text Box of Data Type Date XXX.Value
> run-time property against a constant?
>
> Is it dependent on the format chosen for dates?
> _________________
> Regards,
> David Hodgdon
> ---------------------------------------
> Sent from YesSoftware forum
> http://forums.codecharge.com/
>

peterr


Posts: 5971
Posted: 04/26/2005, 8:55 PM

What is "6/9/2005"? June 9th or September 6th?
This is not just a question from me, but the ASP program is probably just as confused and may randomly interpret it.
Secondly, since you're comparing text (which the Value property returns) then I'm not sure if compaing the two run-timeproperties works reliably.
So first I'd check what's returned by XXX.Value :
response.write XXX.Value
response.end

Or check if both are interpretted properly:
response.write FormatDateTime(XXX.Value , 1) & ", " & FormatDateTime("6/9/2005", 1)
(based on http://www.winguides.com/scripting/reference.php?id=57)

Then you may want to use some date functions to compare 2 values:
http://www.winguides.com/scripting/reference.php?category=23
http://www.google.com/search?hl=en&q=vbscript+comparing+dates
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com
View profile  Send private message
dhodgdon

Posts: 80
Posted: 04/26/2005, 10:19 PM

Quick response before I dig into both suggestions. 6/9/2005 is intended to be June 9th.
_________________
Regards,
David Hodgdon
View profile  Send private message
dhodgdon

Posts: 80
Posted: 04/28/2005, 1:21 PM

Here is why using the constants didn't work but the xxx.value compare did. This is specific to MS Access databases but it may apply to others.

Details can be found in the MS Knowledge Base article 210276:
http://support.microsoft.com/default.aspx?scid=kb;en-us;210276

"Access stores the Date/Time data type as a double-precision, floating-point number up to 15 decimal places. The integer part of the double-precision number represents the date. The decimal portion represents the time."

Everything below assumes that you have declared the Data Type of the MS Access Field Name as Date/Time and that the Data Type of the control in CCS is Date.

If you want to use a date constant use the DateValue() function with the date in quotes between the (), eg. DateValue("4/28/2005"). So a typical useage would be:
If form.control.value > DateValue("4/28/2005") then...

I didn't have a problem when comparing form.control.value with form.control1.value because they are the same data type and in the same format. I tested the use of DateValue() with lots of dates using all types of compares and logical combinations of compares and they all worked as expected.

Similar functions are available for Time and for a combination of Date & Time and fully documented in the MS Knowledge Base article referenced above.
_________________
Regards,
David Hodgdon
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.