Print Page | Close Window

Between dates.... a strange behave

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=3961
Printed Date: 30 March 2026 at 3:20am
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Between dates.... a strange behave
Posted By: exepm2
Subject: Between dates.... a strange behave
Date Posted: 30 June 2003 at 12:24pm

Hi there, I've a nice sql, like this:

SELECT * FROM registro where status like '0' and pretendida between #01/06/2003# and #30/06/2003# order by pretendida desc

pretendida means expected, it`s a date format field in the mdb,  the problem is that I get many rows from the mdb and some outsite the range of the dates.

I tried LCID codes but it's all on its right way to dd/mm/yyyy.

so now what?




Replies:
Posted By: faubo
Date Posted: 30 June 2003 at 2:28pm

I had this problem with Access.

I just change the LCID to US code before the query and change back to the brazilian to show the right format for my users.

It's working perfectly.



-------------
http://www.conhecerparaconservar.org - I don't know how to make you click here


Posted By: exepm2
Date Posted: 01 July 2003 at 6:08am

Thank you very much faubo, but it didn't work in my asp.
Finally I found a good answer at http://www.4guysfromrolla.com - www.4guysfromrolla.com

I had to change my dates without LCID, I had to made a Function that change the month xx/06/xxxx to xx-jun-xxxx, in that way it works with mdb files because they store dates in its particular way of counting day y time since 30-dec-1899.

<%

Function MediumDate (str)

DIM aDay

DIM aMonth

DIM aYear

aDay=Day(str)

aMonth=Monthname(Month(str),true)

aYear=Year(str)

Mediumdate= aDay & "-" & aMonth & "-" & aYear

END Function

%>

<%

Dim SqlJunk,a1,a2

Set dbGlobalWeb = Server.CreateObject("ADODB.Connection")

if request.form("donde")="instalaciones" then

dbGlobalWeb.Open("instalaciones")

end if

a1 = request.form("fecha1")

a2 = request.form("fecha2")

 

SqlJunk = "SELECT * FROM registro where status like '0' and pretendida "

 

sqljunk = sqljunk & " between #"

sqljunk = sqljunk & mediumdate(request.form("fecha1"))

sqljunk = sqljunk & "# and #"

sqljunk = sqljunk & mediumdate(request.form("fecha2"))

sqljunk = sqljunk & "# order by pretendida desc "




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net