Solved

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

Posted on 2008-06-11
6
1,994 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
6 Comments
 

Author Comment

by:Nayel
Comment Utility
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 36

Expert Comment

by:Geert Gruwez
Comment Utility
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
Comment Utility


Problem not solved. This will not run in delphi. And my date comes from datetime picker
0
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
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
Comment Utility
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 50 total points
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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 article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

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

8 Experts available now in Live!

Get 1:1 Help Now