Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

can anyone tell me what's wrong with the querystring below?

 

sqlquery = "SELECT * FROM tblBuys WHERE convert(varchar, BuyDate,103) = '" & Format(Date.Today, "dd/mm/yyyy") & "' ORDER BY BuyKey"

 

Thanks in advance.

George C.K. Low

Posted

What error are you getting...

 

Also Have you tried adding the size of the varchar to be created.

sqlquery = "SELECT * FROM tblBuys WHERE convert(varchar(20), BuyDate,103) = '" & Format(Date.Today, "dd/mm/yyyy") & "' ORDER BY BuyKey"

 

can anyone tell me what's wrong with the querystring below?

 

sqlquery = "SELECT * FROM tblBuys WHERE convert(varchar, BuyDate,103) = '" & Format(Date.Today, "dd/mm/yyyy") & "' ORDER BY BuyKey"

 

Thanks in advance.

Glenn "Mykre" Wilson, DirectX MVP

Inner Realm

Managed DirectX and Game Programming Resources

  • *Experts*
Posted

Also, make sure you mention the Database you're using as the formatting of dates is different for Access vs. SQL Server (for example).

 

I'm glad you removed the "CONVERT" from your date column. If it were already a date, there was no need to convert it. Plus, a convert to varchar would not only be slower (the DB would have to convert every row) but the compare would be slower (string based vs. date based).

 

The only thing I'd suggest adding is the use of ToString on the date:

sqlquery = "SELECT * FROM tblBuys WHERE BuyDate= #" & Date.Today.ToString("MM/dd/yyyy") & "# ORDER BY BuyKey"

 

-ner

"I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...