Solved

Problem in mySQL query with VB 6.0

Posted on 2004-08-12
5
141 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
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

762 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now