Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
|
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old September 21st, 2006, 09:23 AM
Registered User
 
Join Date: Sep 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default SQL Date query in Excel VBA

Hi,

I want to retrieve data into Excel using SQL executed from VBA. The SQL works fine until I try WHERE date > this date.

The date code I tried is this below but I can't get it to work and don't if I should be using ' # " or to_char function. Can anyone help it is driving me bananas!

"SELECT MEMBER.MEMBER_NO, to_char(MEMBER_NOTES.NOTE_DATE, 'mm/dd/yyyy') as NOTEDATE FROM MEMBER INNER JOIN MEMBER_NOTES ON MEMBER_NOTES.MEMBER_NO = MEMBER.MEMBER_NO WHERE TO_CHAR(MEMBER_NOTES.NOTE_DATE, '#MM/DD/YYYY#') > TO_DATE(#04/04/2006#, 'MM/DD/YYYY')"

Any assistance greatly appreciated.

Lane


 
Old September 25th, 2006, 02:50 PM
Registered User
 
Join Date: Sep 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Are you pulling from an Access database or an SQL server?

If it's an SQL server, then drop the '#' around the dates and it should work.

 
Old September 27th, 2006, 02:04 AM
Registered User
 
Join Date: Sep 2006
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It's an oracle database on a unix server. I have tried it without '#'.






Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel vba query not working, pls help me. kavisundar SQL Language 0 May 16th, 2007 10:14 AM
A simple question about date in VBA for Excel 2002 Trancefuzion Excel VBA 2 July 29th, 2004 04:37 AM
Excel VBA to SQL & back to VBA edesousa Excel VBA 1 June 1st, 2004 02:39 AM
Date in Access VBA (SQL) Kenny Alligood Access VBA 2 September 14th, 2003 08:35 AM
Convert String Date to Date for a SQL Query tdaustin Classic ASP Basics 4 July 7th, 2003 06:01 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.