I need help with a Date Lookup Query (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


DaveKstl -> I need help with a Date Lookup Query (1/25/2008 15:35:22)

I have a Text Field in a form DateText

In my Table I have 3 date fields:

BegDate________EndDate_________PeriodDate
01/05/2008_____ 02/04/2008______02/01/2008

My challenge is the syntax for the query

mySQL = "Select PeriodDate From Table Where Request.Form("DateText") Between BegDate AND EndDate"

I realize that the SQL syntax is incorrect, I have tried several methods and get either Data mismatch or other errors.

How do I convert a Text Field to be used in the above query?

Thanks




Spooky -> RE: I need help with a Date Lookup Query (1/25/2008 16:18:59)

Which dates form part of the query?




DaveKstl -> RE: I need help with a Date Lookup Query (1/25/2008 17:41:31)

Not sure I understand but

mySQL = "Select PeriodDate From Table Where Request.Form("DateText") Between BegDate AND EndDate"

The customer enters the Request.Form("DateText") let's say 1/25/2008 as a text entry.

The lookup then check for a value Between BegDate (beginning) AND EndDate (end).

So the BegDate = 01/05/2008 and the EndDate in the table is 02/04/2008, 1/25/2008 falls between so I should get a return PeriodDate of 2/1/2008

Unfortunately, I am challenged with the Text Filed form the form being changed to a value value that works in the query.





Spooky -> RE: I need help with a Date Lookup Query (1/25/2008 19:27:26)


mySQL = "Select PeriodDate From Table Where #"&DtVar&"#  Between BegDate AND EndDate" 

You would need to ensure DtVar is a valid date something like so :

DtVar = Request.Form("DateText")
If isDate(DtVar) then
' ok
else
 'error
end if




DaveKstl -> RE: I need help with a Date Lookup Query (1/28/2008 7:31:06)

quote:

mySQL = "Select PeriodDate From Table Where #"&DtVar&"# Between BegDate AND EndDate"


Thanks.

I should know this, but I don't

So a text field does not need to be converted before the data is placed in a query? It is the query that adjusts the data before it is written.

So:

Date is #&DteVar&#
Number is '&NumVar&'
Text is '"&TextVar&&"'




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
6.054688E-02