?
Solved

Problem in mySQL query with VB 6.0

Posted on 2004-08-12
5
Medium Priority
?
146 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…
Suggested Courses
Course of the Month15 days, 15 hours left to enroll

741 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