PEAR Packages
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsPHP RelatedPEAR Packages

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
  #1  
Old June 1st, 2006, 09:48 AM
jpadie jpadie is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 2 jpadie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
PEAR::DB connecting to Access via ODBC - problems with dates

I am using the following code to access and query an ms access database.
php Code:
Original - php Code
  1.  
  2. $sql ="
  3. SELECT
  4.     Times.datDate,
  5.     [Project Details].strProjectName,
  6.     [Project Details].strCustomer,
  7.     Times.dblHours,
  8.     Times.memDescription
  9. FROM
  10.     [Project Details]
  11.     INNER JOIN
  12.         Times
  13.         ON
  14.         [Project Details].lngProjectID = Times.lngProjectID
  15. WHERE
  16.     Times.datDate
  17.     Between ? And ?";
  18.  
  19. $res = $db->getAll($sql, array("2006-05-01","2006-06-01") );


the connection works just fine and in my production code there is plenty of error checking.

the problem i have is formatting the dates correctly for inclusion in the query parameter. i have tried just about every combination i can think of and get, variously, empty result sets and errors. MS access seems to want something akin to a number but including the slashes and surrounded by hash signs.
ie
php Code:
Original - php Code
  1.  
  2. between #5/1/2005# And #6/1/2006#
  3.  


but of course we can't give this type of data in php as the hash sign is a commment designator. yes i could output a specific ascii character but this seems really backwards.

the relevant field type in access is date/time.

does anyone have any experience of how to use dates in queries to access databases across odbc using PEARB?

thanks
justin



Reply With Quote
  #2  
Old June 1st, 2006, 11:36 AM
jpadie jpadie is offline
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 2 jpadie User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
RE: PEAR::DB connecting to Access via ODBC - problems with dates

to all those who take the time to read, there are two solutions...

solution 1 - replace the ? placeholder (which is for scalars) with the ! for literals. then forget the quirky access date format and use the standard yyyy-mm-dd variant.

solution 2 - replace the criteria with a single criterion
php Code:
Original - php Code
  1.  
  2. where format(datDate, 'mmmm') = ?

and set the array parameter to "May".

clearly solution 1 is more flexible and is the implementation i was after. The second is quite neat for ease of reference. I suspect that it may not be very efficient in terms of processing time however.

thanks
Justin

Reply With Quote
Reply

Viewing: Codewalkers ForumsPHP RelatedPEAR Packages > PEAR::DB connecting to Access via ODBC - problems with dates


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
Create the Optimal Architecture for your Critical Applications
Warburton's the largest independently owned bakery in the UK faced a number of difficult challenges in providing the most robust yet efficient IT infrastructure for their organization's success. IBM's services combined with their xSeries servers created the perfect platform for their SAP environment with sufficient flexibility, and did so in very time effective fashion.

Request Your Free Technology Downloads!
 
Five Best Practices for Deploying a Successful Service-Oriented Architecture
This white paper describes the benefits you can expect with SOA, and how IBM can help take your business there.

Request Your Free Technology Downloads!
 
Gartner Magic Quadrant for Application Delivery Controllers
Gartner summarizes its view on Application Delivery Controllers, evaluates strengths and weaknesses of solutions, and provides Magic Quadrant reporting for a quick comparison across all vendors. Learn from Gartner how you can benefit from an all-in-one device like Citrix NetScaler that delivers the highest levels of availability, performance and security.

Request Your Free Technology Downloads!
 
Knowledge is Power
What you don't know can hurt you, and is likely costing you money and increasing your security risks during an era of scarce resources. This white paper proposes six key strategies that enterprise security managers can use to improve their network defense posture.

Request Your Free Technology Downloads!
 
Rationalizing the Multi-Tool Environment
The rationalized multi-tool approach is flexible, scalable and cost effective. It provides the necessary input to the IT service management business processes. It preserves prior investments in monitoring tools, empowers technologists to select the best tools with which to do their jobs, and enhances effective response to incidents.

Request Your Free Technology Downloads!
 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2010 by Developer Shed. All rights reserved. DS Cluster 8 Hosted by Hostway
For more Enterprise Application Development news, visit eWeek