[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

How do I select information between 2 dates in delphi access  mdb

Posted on 2008-06-11
6
Medium Priority
?
2,298 Views
Last Modified: 2008-07-01
I have the following SQL
I am adding to delphi codes this query (db is a mdb-access file)

Select SUM(Hours)
From Empolyee
Where (name = 'name') And (date >=#01-06-2008#  and date <= #04-06-2008#)

This query is not turning anything but it is just making the sum for the all data's belong to the name.
So the date selection is not working.

Any idea why?
0
Comment
Question by:Nayel
[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
6 Comments
 

Author Comment

by:Nayel
ID: 21758926
By the way.

If I do it (date >=#2008/06/01 #  and date <= #2008/06/04#)
then I get the results. But I need to add it from delphi.

sql.add('Select ...')
sql.add('From ....')
sql.add('Where ??????????)
0
 
LVL 38

Expert Comment

by:Geert Gruwez
ID: 21759258
selection from last 7 days :


sql.Add('WHERE date >= :date1 and date <= :date2');
sql.prepare;
sql.parambyName('date1').AsDateTime := Now - 7;
sql.ParamByName('date2').AsDateTime := Now;
sql.Open;

Open in new window

0
 

Author Comment

by:Nayel
ID: 21759277


Problem not solved. This will not run in delphi. And my date comes from datetime picker
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 101

Expert Comment

by:mlmcc
ID: 21761298
Can you give the full select/filter statement.

You should be able to use something like
'date >= ' &  StartDAtePicker.Date & ' and date <= ' & enddatepicker.date

mlmcc
0
 
LVL 13

Expert Comment

by:rfwoolf
ID: 21761760
Go into MS Access and build your query in SQL form there. When that works, then go into delphi and build it.
0
 
LVL 4

Accepted Solution

by:
spk2000ar earned 100 total points
ID: 21880741
You can do something like this:


s := shortdateformat;
shortdateformat := "aaaa/mm/dd";
sql.add('Select SUM(Hours)')
sql.add('From Empolyee')
sql.add('Where (name = "name") And (date BETWEEN ' + QuotedStr(DateToStr(DateTimePicker1.Date)) + ' and ' + QuotedStr(DateToStr(DateTimePicker2.Date)) + '))';
shortdateformat := s;

Open in new window

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
This video teaches viewers about errors in exception handling.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

656 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