Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Problem in mySQL query with VB 6.0

Posted on 2004-08-12
5
Medium Priority
?
147 Views
Last Modified: 2010-05-02
Hi Experts,

Can anyone figure out whats wrong with my query below? Im using mySQL database in vb 6.0

SELECT schedule_info1.*, Format([SCH_startdate],"mm/dd/yyyy") AS Expr1
FROM schedule_info1
WHERE (((Format([SCH_startdate],"mm/dd/yyyy"))=#08/12/2004#));

The compiler is telling that there is an error in SQL syntax.

Thanks in advance
0
Comment
Question by:Phoenixric
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
5 Comments
 
LVL 18

Expert Comment

by:JR2003
ID: 11781923
I'm not at all familiar with mySQL I've only used Oracle and Access but I'd try the following:

Do you need that semi-colon at the end of the SQL?
Does the Format statement work with mySQL as it's also a VB function?
Instead of
WHERE (((Format([SCH_startdate],"mm/dd/yyyy"))=#08/12/2004#));
shouldnt' it read
WHERE Format([SCH_startdate],"mm/dd/yyyy") = "08/12/2004"
or
WHERE SCH_startdate = "#08/12/2004#"
?
0
 
LVL 3

Author Comment

by:Phoenixric
ID: 11782276
Hi,

Thanks for the quick reply, Im also beginning to learn mySQL and its really a hard time for us using ACESS , Oracle finding this stuff with big difference, its slightly differs to SQL Server also. . :-(

Researching for the solution, I.ve found this page :
http://dev.mysql.com/doc/mysql/en/Date_and_time_functions.html

Realizing that if I'd stick with my code above, I will never ever find the solution for its quite very far.

I ended up with this query and its working fine now and be able to combine another criteria for time too.
cause the [SCH_startdate] field  format is mm/dd/yyyy hh:mm:ss AM/PM

 cSQL = "SELECT schedule_info.* From schedule_info " & _
             "WHERE DATE_FORMAT(SCH_startdate,'%m/%d/%Y') ='" & Date & "' " & _
             "AND DATE_FORMAT(SCH_startdate,'%r') ='" & Time & "' "

Thanks a lot

PhoenixRic ;-)
0
 
LVL 1

Accepted Solution

by:
GhostMod earned 0 total points
ID: 12528637
PAQed with points refunded (300)

GhostMod
Community Support Moderator
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question