Forums

This topic is locked

using calc dates

Posted 11 Dec 2001 00:00:44
1
has voted
11 Dec 2001 00:00:44 Alexander Dirks posted:
with a variable
_date

and the possible value
(DatAdd('d', 30, Date()))

i want to create a sql-statement like this:

'select * from evenst where (eventdate>=date()) and (eventdate<=MMColParam)

MMColParam : Request.Form("_date"

It does not work!
it seems that i could not use a function for a variables value in sql???

I want to create a function for selecting recordsets like this:
events in the next week, month, this year

Anybody here, who could tell me what to to???

Anybody here, who could tell me what to to???






Edited by - adm on 11 Dec 2001 00:07:55

Replies

Replied 13 Dec 2001 20:41:42
13 Dec 2001 20:41:42 Joel Martinez replied:
That should work...
What error do you get? do you get the wrong resultset back?

try this, on the page that gets the recordset, type this before the recordset happens:

<%="select * from evenst where (eventdate>='"&date()&"') and (eventdate<='"&Request.Form("_date"&"')%>

Then see what sql that gives you... if you are using access, you may have to replace the single quotes with #s
you should be able to figure this out with a little bit of debugging

Joel Martinez [ ]
----------
E-Commerce Concepts with Ultradev...pre-order yours at
www.basic-ultradev.com/ecomm_concepts/
Replied 14 Dec 2001 20:53:16
14 Dec 2001 20:53:16 Alexander Dirks replied:
hi! thanks a lot for replying!
i tried what you have suggested!
it does not work!
the execute of sql takes as variable the function (dateadd(...) and not the result of it!
"missing operator" is the failure
original:
[Microsoft][ODBC Microsoft Access Driver] Syntaxfehler (fehlender Operator) in Abfrageausdruck 'Veranstaltungsdatum <= (DatAdd(''d'', 3, Date()))'.

have you any idea???

thanks.


Replied 14 Dec 2001 21:30:44
14 Dec 2001 21:30:44 Joel Martinez replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>"missing operator" is the failure
original:
[Microsoft][ODBC Microsoft Access Driver] Syntaxfehler (fehlender Operator) in Abfrageausdruck 'Veranstaltungsdatum &lt;= (DatAdd(''d'', 3, Date()))'.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>Well, I think the problem might lie in your syntax, instead of <b>(DatAdd(''d'', 3, Date()))</b>
try
<b>(DateAdd('d', 3, Date()))</b>

If that doesn't work, see if you can find a way to pass in the result of the function instead of using it in the sql.

Joel Martinez [ ]
----------
E-Commerce Concepts with Ultradev...pre-order yours at
www.basic-ultradev.com/ecomm_concepts/
Replied 14 Dec 2001 21:34:50
14 Dec 2001 21:34:50 Alexander Dirks replied:
i notified the syntax errot and i wrote it correct now, but it does not work!!
when i use the function itself in the sql statement, it works!!
when i use a variable which is filled with the function, it does not work!
i think it would be the only way for me to run the function first and the take the value for the execution of the sql...

thank a lot.

adm

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>"missing operator" is the failure
original:
[Microsoft][ODBC Microsoft Access Driver] Syntaxfehler (fehlender Operator) in Abfrageausdruck 'Veranstaltungsdatum &lt;= (DatAdd(''d'', 3, Date()))'.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>Well, I think the problem might lie in your syntax, instead of <b>(DatAdd(''d'', 3, Date()))</b>
try
<b>(DateAdd('d', 3, Date()))</b>

If that doesn't work, see if you can find a way to pass in the result of the function instead of using it in the sql.

Joel Martinez [ ]
----------
E-Commerce Concepts with Ultradev...pre-order yours at
www.basic-ultradev.com/ecomm_concepts/
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>

Reply to this topic