Tuesday, March 27, 2012

Date Query

Good Morning to all

I wrote a query to access some data from sql server ,my query is as follows

strsel = "select * from schedule where sector_id='" & str_sec_id & "' And dep_date = " & bb & ""

bb is the date transferred from the other module

i want to check the dep_date as short date format.because bb is in short date format.

in the above checking i am not getting the query result

please look on this code

Regards

Unni

what you are passing in bb, if bb is datetime variable just do this bb.toshortDateString().

furthermore, try Response.write(strsel). so that you can get the actualy query on browser then try to run it in sql see what u get

cheers

|||

unnik_pulikkal:

strsel = "select * from schedule where sector_id='" & str_sec_id & "' And dep_date = " & bb & ""

Also it looks like you are forgetting the single quotes around your date field:

"select * from schedule where selector_id = 3 And dep_date = 1/3/2007"will not give you the results that you want

"select * from schedule where selector_id = 3 And dep_date = '1/3/2007'"will give you the results you want

Peace,

No comments:

Post a Comment