Wrox Home  
Search P2P Archive for: Go

  Return to Index  

access thread: substituting values for date fields


Message #1 by puppy1978@r... on Mon, 30 Apr 2001 11:56:15
Hi p2p friends,

           I use Ms-Access Database.

    The problem is in executing SQL queries with date  fields in

the codition checking part.I was able to give only the  field name which 

	

contains the date.We are not allowed to give the date directly.



	For example consider the table DATE_TABLE with date fields DATE1 

and 

DATE2.The query is successful if I write

        " SELECT * FROM TABLE WHERE DATE1 < DATE2  ".

 But if i substitute the value for date  like '12/12/1980'   instead

 of DATE1 or DATE2 directly it doesn't 	work. 

For example the following query is not successful :

        " SELECT * FROM TABLE WHERE DATE1 < 09/11/2000 ".

	

Please help.Thanks in advance. 



        ---priya 



Message #2 by "John Ruff" <John_Ruff@m...> on Mon, 30 Apr 2001 04:03:55 -0700
Place the # sign before and after the date.  This tells the SQL statement

this is a date.



"SELECT * FROM TABLB WERE DATE1 < #09/11/2000#"



John Ruff - The Eternal Optimist :)





-----Original Message-----

From:	puppy1978@r... [mailto:puppy1978@r...]

Sent:	Monday, April 30, 2001 11:56 AM

To:	Access

Subject:	[access] substituting values for date fields



Hi p2p friends,

           I use Ms-Access Database.

    The problem is in executing SQL queries with date  fields in

the codition checking part.I was able to give only the  field name which



contains the date.We are not allowed to give the date directly.



	For example consider the table DATE_TABLE with date fields DATE1

and

DATE2.The query is successful if I write

        " SELECT * FROM TABLE WHERE DATE1 < DATE2  ".

 But if i substitute the value for date  like '12/12/1980'   instead

 of DATE1 or DATE2 directly it doesn't 	work.

For example the following query is not successful :

        " SELECT * FROM TABLE WHERE DATE1 < 09/11/2000 ".



Please help.Thanks in advance.



        ---priya



Message #3 by Dennis Wathen <wathen.dennis@c...> on Mon, 30 Apr 2001 07:30:14 -0500
Priya



You must use # on both sides of a literal date value in an Access database.

Using quotation marks indicates a string.  In the second example without #

or ' the query tries to perform division because of the /.  



Dennis





-----Original Message-----

From: puppy1978@r... [mailto:puppy1978@r...]

Sent: Monday, April 30, 2001 6:56 AM

To: Access

Subject: [access] substituting values for date fields





Hi p2p friends,

           I use Ms-Access Database.

    The problem is in executing SQL queries with date  fields in

the codition checking part.I was able to give only the  field name which 

	

contains the date.We are not allowed to give the date directly.



	For example consider the table DATE_TABLE with date fields DATE1 

and 

DATE2.The query is successful if I write

        " SELECT * FROM TABLE WHERE DATE1 < DATE2  ".

 But if i substitute the value for date  like '12/12/1980'   instead

 of DATE1 or DATE2 directly it doesn't 	work. 

For example the following query is not successful :

        " SELECT * FROM TABLE WHERE DATE1 < 09/11/2000 ".

	

Please help.Thanks in advance. 



        ---priya 









  Return to Index