ASP Forum
select date from access database
phobos | Posted 4:04pm 8. October 2005 Server Time |

I have problem wiht selecting date from database(access),
im allways geting error: Syntax error in date in query expression

in database is date set to "short date"

I tryed so many different options but its still not working

regards
thorpe | Posted 4:42pm 8. October 2005 Server Time |

cant help if we cant see your query.
phobos | Posted 12:24am 9. October 2005 Server Time |

MY CODE:

<%
Dim cnnBaze
Dim RSBaze  
Dim PotBaze  
Dim SQL
Dim CurentDate
Dim LastDate

CurentDate = FormatDateTime(date(),2)
LastDate = date()+7



PotBaze = Server.MapPath("databases/bazica.mdb")
Set cnnBaze = Server.CreateObject("ADODB.Connection")
cnnBaze.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & PotBaze & ";"
SQL = "select * from ponudba WHERE datum ???????????????"
Set RSBaze = cnnBaze.Execute(SQL)

%>

??????????????? = Here I would like to show dates between CurentDate AND LastDate

Sebastijan
greyknght1 | Posted 8:29am 10. October 2005 Server Time |

WHERE datum BETWEEN '" & CurrentDate & "' AND '" & LastDate & "'"
Ophelia | Posted 8:55am 10. October 2005 Server Time |

Or

WHERE datum >='" & CurrentDate & "' AND datum <='" & LastDate & "'"

Off topic - are you the DG Phobos?
phobos | Posted 10:57am 10. October 2005 Server Time |

HMMMMM

I was trying this examples before too.

Im geting error:
Error Type:
Microsoft JET Database Engine (0x80040E07)
Data type mismatch in criteria expression.

I have tryed with:
SQL = "SELECT * FROM ponudba WHERE datum BETWEEN '" & CurrentDate & "' AND '" & LastDate & "'"
SQL = "SELECT * FROM ponudba WHERE datum >='" & CurrentDate & "' AND datum <='" & LastDate & "'"
SQL = "SELECT * FROM ponudba WHERE datum >='# & CurrentDate & #' AND datum <='# & LastDate & #'"
SQL = "SELECT * FROM ponudba WHERE datum BETWEEN '# & CurrentDate & #' AND '# & LastDate & #'"

working query: SQL = "select * from ponudba where datum = #10/10/2005#"
There must be smth wrong with formating of the date.
Do someone have any idea what could it be?

thnx for helping


ps
Ophelia, what it means the DG phobos?

phobos | Posted 11:37pm 13. October 2005 Server Time |

mhm......any new idea??
pussy cat | Posted 2:51am 14. October 2005 Server Time |


SQL = "SELECT * FROM ponudba WHERE datum BETWEEN '" & CurrentDate & "' AND '" & LastDate & "'"
should work have you tried:


SQL = "SELECT * FROM ponudba WHERE datum BETWEEN '01/01/05' AND '31/09/05'"
to see if that works


Reply to Post select date from access database



Back to Forum Page