Help With SQL Select Statement

DonnaF

Active member
Joined
Mar 20, 2003
Messages
30
I have an Access Database, that Im binding to a datagrid in a Visual Basic Program. The Task_Date is MM/DD/CCYY. I want to select records based on if the task date matches the current date . Here is my Select Statement. Im not getting any hits, even though I have records that match todays date. I know there are rules about apostrophes in the Select statement, but Im not sure what the format is for dates. Can someone give me the correct format and/or point me to somewhere that has it documented?

Thanks, Donna


DataAdapter.SelectCommand.CommandText = _
"SELECT Task_Date, Task_Description FROM TasksTable " & _
"WHERE Task_Date = " & Today & ""
 
try this:

Code:
DataAdapter.SelectCommand.CommandText = _
"SELECT Task_Date, Task_Description FROM TasksTable " & _
"WHERE Task_Date = #" & Today & "#"

or if that fails this:

Code:
DataAdapter.SelectCommand.CommandText = _
"SELECT Task_Date, Task_Description FROM TasksTable " & _
"WHERE Task_Date = " & Today
 
problem with date

Maybe this is a silly question, but im new to this complete approach of an Access database and SQL statements.

What are the #s for?
And what ways are there to compare dates?
Is it possible using = < > for looking if dates are equal, bigger smaller then another date? or are there functions in sql for it?

im trying to compare a date as well, but it doesnt do the query at al

Dim strSelect As String = "select * from FAQ"
strSelect = strSelect & "WHERE Date>" & Now().AddMonths(-1)

and then i execute it to fill a dataset with a dataadapter. But it returns all fields in the table FAQ, instead of the ones from only one day old?!

Can someone help me??

thanks, Gertie
 
thanks you,

I hope i get this started today. Because im working against a deadline, i only have 3 days to make a FAQ page. It is not a big one, but al in al it still is a big task!

see you,

gertie
 
Thanks guys,

Its working, and now im going on to the next level!!

Its like super mario bross, you kill one mean boss, you get another!!

No problem, just let them come!!
Ive picked up enough mushrooms and flowers!! *pling pling*
:cool: :D
 
Back
Top