Wrox Programmer Forums
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old March 19th, 2004, 06:36 AM
Authorized User
 
Join Date: Dec 2003
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default date type queries

hello

in my table DOA(date of appointment),DOR(date of retirement) field
is there now i want to calculate Quaffing service like no of years,
no of month, no of days completed so how I should write queries or
function please explain me step by step


Mohamed Mohiddin
Officer
__________________
Mohamed Mohiddin
Officer
 
Old March 19th, 2004, 03:05 PM
Authorized User
 
Join Date: Feb 2004
Posts: 98
Thanks: 0
Thanked 0 Times in 0 Posts
Default

This is a broad area that depends on many variables that you have not provided. If you wanted to know how to query on people with greater than 5 years of service, a solution can be provided. I would begin by looking at the help on the DateDiff function. Specific syntax varies with whether you are working from recordset field values, variables or control contents.

In order to get started, in the immediate pane of the debug window, pressing 'Enter' after the following:

?datediff("m","March 01, 2004","January 3, 2001")

yeilds:

-38

You can also simply subtract one date value, as indicated by the delimiters below, again in the immediated window, from another to return the number of days:

?#March 01, 2004# - #January 3, 2001#
 1153

To get Years, Months and Days is a bit more complex as you need to subtract successive intervals from the difference. ie, 32 months is 2 years worth of months less than 32 months being 2 years and (32 months - 12 months/year * 2 years = 32 - 24 = 8) 8 months. The same and more is required for days in order to account for month and leap year lengths.

Ciao
Jürgen Welz
Edmonton AB Canada
[email protected]





Similar Threads
Thread Thread Starter Forum Replies Last Post
Date Type checking NEO1976 XSLT 5 February 1st, 2007 10:37 AM
date type queries mohiddin52 Access 5 July 29th, 2005 03:32 PM
date and price queries beanfair Access 1 April 20th, 2005 03:34 AM
date type queries mohiddin52 Access 1 January 11th, 2005 01:41 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.