Seach by date (Full Version)

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



Message


chadb -> Seach by date (5/6/2008 10:57:29)

Can someone tell me what I am doing wrong. I am trying to search by greater than date.

fp_sQry="SELECT * FROM Item WHERE (TranDate <= 4/15/2008)"

It never returns any records.




BeTheBall -> RE: Seach by date (5/6/2008 12:33:39)

Access database? If so, try this:

SELECT * FROM Item WHERE (TranDate <= #4/15/2008#)




chadb -> RE: Seach by date (5/6/2008 12:57:56)

quote:

(TranDate <= #4/15/2008#)


Yes, that is perfect. One other question, Can I convert a text access field to an int?

I need this to be an int. not char. Is that possible? With the current way, it returns all records.

fp_sQry="SELECT * FROM Item WHERE (Diff < '-5')"




BeTheBall -> RE: Seach by date (5/6/2008 14:04:54)

If Diff is a numeric field then you should NOT surround the value with single quotes. In other words, the SQL should be:

fp_sQry="SELECT * FROM Item WHERE (Diff < -5)"

General rule is as follows:

If the database field is text - Surround the value with single quotes
If the database field is a date - Surround the value with #
Otherwise, use no delimiter




Page: [1]

Valid CSS!




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