473,396 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Using Datediff

Hi there! I hope you can help me!

I have the following code:

SELECT COUNT(Applications.[Date Application Received]) AS TOTAL
FROM Applications
WHERE DateDiff('d',[Date Application Received],Date()) <6 AND
[Statement/Cert Letter/] = "Certificate";

Which returns the number of applications received between todays date
and 5 days previous.

However, I want to modify this so that the user enters both the first
date and the second date. I've tried experimenting by replacing the
Date() with an actual date, but it doesn't return the correct result.
Even if I put the same date that the Date() function would use. I'm
not sure how I get a prompt to appear so that the user can input the
dates anyway, although it sometimes happens for some reason!

Any help would be hugely appreciated! Thank you in advance!

Contro

Nov 13 '05 #1
2 1923
On 8 Jul 2005 05:07:40 -0700, Contro wrote:
Hi there! I hope you can help me!

I have the following code:

SELECT COUNT(Applications.[Date Application Received]) AS TOTAL
FROM Applications
WHERE DateDiff('d',[Date Application Received],Date()) <6 AND
[Statement/Cert Letter/] = "Certificate";

Which returns the number of applications received between todays date
and 5 days previous.

However, I want to modify this so that the user enters both the first
date and the second date. I've tried experimenting by replacing the
Date() with an actual date, but it doesn't return the correct result.
Even if I put the same date that the Date() function would use. I'm
not sure how I get a prompt to appear so that the user can input the
dates anyway, although it sometimes happens for some reason!

Any help would be hugely appreciated! Thank you in advance!

Contro


I don't understand why you would want to enter both dates, but the
following works for me:
DateDiff("d",[Enter Date1],[Enter Date2])

If you enter 1/1/2005 and 6/1/2005 the difference is 151 days, which
will be returned for each record in the query.

I think you probably would want to enter just one of the arguments
manually
DateDiff("d",[Enter From date],Date())
or
DateDiff("d",[Date Application Received],[Enter To Date])
--
Fred
Please only reply to this newsgroup.
I do not reply to personal email.
Nov 13 '05 #2
That's great! I'll give that a try (probably Monday now), but I'm sure
it will work! I think what got me was the American date setting (I'm
from England). I thought that the code wasn't working as the
application received date is input in the English format (DDMMYYYY
although Month was "MAR" or what not).

Anyway, I'll give that a go, and thank you again!

Contro

Nov 13 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: inamori | last post by:
I face that problems 07/01/2003 06/30/2006 ---------> it should be 3 01/01/2003 02/28/2005 --------->could i get 2 years and 2 months 01/01/2003 03/01/2005 ...
19
by: Lauren Quantrell | last post by:
I have a stored procedure using Convert where the exact same Convert string works in the SELECT portion of the procedure but fails in the WHERE portion. The entire SP is listed below....
1
by: intl04 | last post by:
I'm trying to set up a query that will include a new field ('Days until completion') whose value is derived from the DateDiff function. I think I have the syntax correct but am not sure. Days...
7
by: Adrian | last post by:
I hit on this problem converting a VB.NET insurance application to C#. Age next birthday calculated from date of birth is often needed in insurance premium calculations. Originally done using...
3
by: Price Brattin | last post by:
Why is the DateDiff function in the following code returning zero? Dim FileDate, TransmissionDate as Date Dim TranDay, FileDay, DayDiff as Inteter TransmissionDate = #2/5/2006 1:57:56 PM#...
2
by: OdAwG | last post by:
Hello Again Access GURU's, Need some help with Conditional Formatting and datediff. What I am trying to do is the following: I have three text boxes with dates in them and what I want to do...
1
by: rn5a | last post by:
I have 2 variables - 'dt1' & 'dt2' - of type DateTime. Assume that one of the values of 'dt1' (which is being retrieved from a DB table) is 27/12/2006 6:54:27 AM & the value of 'dt2' is the current...
1
by: Sultan Ali Alhassni | last post by:
I was trying to use the datediff function in the Update query and I added the following on the upate to field : Datediff("d", , where Sentdate: is a date stored in a table called cycle_table ...
2
by: stephenmcnutt | last post by:
I'm trying to do something that should be trivial. I'm a teacher at an elementary school, and I'm setting up an ASP form page for teachers to vote each afternoon on which dismissal line behaved...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.