473,407 Members | 2,314 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,407 software developers and data experts.

Help with DateDiff query in Access.

20
Query set up as follows: DateDiff("d",[ADATE],[DDATE]) yields difference in days between arrival and departure. Want to adjust the expression so that if the ADATE and DDATE are the same, it will be counted as 1 rather than 0 days.

Any help would be appreciated. Thank you
Sep 30 '10 #1
4 2162
MMcCarthy
14,534 Expert Mod 8TB
Try this ...

Expand|Select|Wrap|Line Numbers
  1. DateDiff("d",[ADATE],[DDATE]-1)
If it results in -1 then try putting it on the ADATE instead.
Sep 30 '10 #2
cambar
20
Already had tried the MMcCarthy approach. Perhaps I was unclear in my initial question. I need an expression that counts days like the DateDiff("d",[ADATE],DDATE])expression does except that for those stays where the person arrives and leaves on the same day, I need it to show 1 day - not 0 as the current expression results in. So, if I run a report based on the needed query, it will show all stays. It will count according to the original expression but will adjust each same-day stay from 0 to 1 day.

Thanks
Sep 30 '10 #3
MMcCarthy
14,534 Expert Mod 8TB
You could use an IIf function.

Expand|Select|Wrap|Line Numbers
  1. IIf(DateDiff("d",[ADATE],[DDATE])=0,1,DateDiff("d",[ADATE],[DDATE]))
Sep 30 '10 #4
Thanks so much. This did the job!
Oct 1 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: sah | last post by:
I need some help with the following query: DECLARE @SRV VARCHAR(20), @date smalldatetime SET @SRV = (select @@servername) SET @date = '20040901' select Srv_Name = @SRV, DB_Name = 'DB_NAME',...
3
by: Dan | last post by:
Hello, Am trying to construct a query that'll both compute elapsed time based on certain criteria and sum this up for a subset of records. Sample Data that I'm working with: Row Ev_Time ...
5
by: angelasg | last post by:
I am working with employee schedules. Each schedule is comprised of segments (shift, lunch, break, training, etc.) that have rankings. Each record has the employee id, the date the shift starts,...
4
by: skinnybloke | last post by:
Hi - a bit new to access. I'm looking for help on if Access can do the following: I have an access database on which I run a SQL query which I export as an excel spreadsheet for sending to a...
15
by: PMBragg | last post by:
Thank you in advance. I'm trying to pull all inventory items from December of the previous year back to 4 years for my accountant. I know this can be done, but I'm drawing a blank. I've tried; ...
5
by: Peter | last post by:
I have a query that returns: Turner Completion Turner Interim 1 Kemp Completion Steel Completion Steel Interim 1 Steel Completion Steel Interim 1 Webb Completion
11
by: deko | last post by:
What's the best way to create a help system for Access 2003? Is MS HTML Help Workshop the way to go? I want to put a clickable control on different forms, that, when clicked, will bring up the...
7
by: Techhead | last post by:
I have a date/time field with a sql format of "datetime" The actual date/time data format is MM/DD/YYYY^hh:mm:ss:pm or "1/25/2007 12:00:16 AM" Both the date and time are combined on the same field...
6
by: Wheeler2008 | last post by:
Hi All, I am currently running a query on a MS Access table, in which I want to be able to compare and total the difference in dates between records. I only have one date field within the table. ...
5
by: lisles | last post by:
i have a page funtion.php which hs the function to connect to the db /* Mysql Connection */ function connect(){ global $db_server,$db_user,$db_pass,$db;//Global Values from the config.php...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.