Date Variable in an SQL statement, how???? 
Author Message
 Date Variable in an SQL statement, how????

When I hard code a date in an SQL statement as follows, it works.

WHERE #08/01/98# BETWEEN [FROM DATE] AND [TO DATE]

But, I want to allow the user to enter in various dates so, I need this
SQL statement to handle a variable like a date.  Please help, I am going
crazy.




Tue, 06 Mar 2001 03:00:00 GMT  
 Date Variable in an SQL statement, how????
The way I do this is to capture the date text and perform whatever
validation is necessary and then I append the # character to the front
and the end of the string.

strdate = "#" & struserdate & "#"

You should now be able to use strdate as the date variable for your SQL
statement.

Hope this helps,

Matt


overheard saying...

Quote:
> When I hard code a date in an SQL statement as follows, it works.

> WHERE #08/01/98# BETWEEN [FROM DATE] AND [TO DATE]

> But, I want to allow the user to enter in various dates so, I need this
> SQL statement to handle a variable like a date.  Please help, I am going
> crazy.



--
Matt Childs



Tue, 06 Mar 2001 03:00:00 GMT  
 Date Variable in an SQL statement, how????
Hi, Steve

    Let's say the date you want is in txtDate.Text:

    "Where #" & txtDate.Text & "# Between [From Date] And [To Date]"

Best,

Mike

Quote:

>When I hard code a date in an SQL statement as follows, it works.

>WHERE #08/01/98# BETWEEN [FROM DATE] AND [TO DATE]

>But, I want to allow the user to enter in various dates so, I need this
>SQL statement to handle a variable like a date.  Please help, I am going
>crazy.





Wed, 07 Mar 2001 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Variable Date in a SQL statement

2. How?-Date as a variable in SQL statement

3. Help with date variable in SQL statements

4. Date Variable in SQL Statement Useage

5. set variable with an sql statement in VBA

6. Formatting a string variable in an SQL statement.

7. Using Variable in SQL Statement

8. Using Variables in an SQL Statement

9. Variable in SQL Statement

10. Using variables in SQL statements

11. Problems passing a string variable to an SQL statement

12. Sql query statement (using a variable)

 

 
Powered by phpBB® Forum Software