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 July 29th, 2005, 04:51 AM
Authorized User
 
Join Date: Dec 2003
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default date type queries

Hi Expert
In my table there are DOE(Date of Entry) and DOR(Date of Retirement)
now I want Total length of service like how many years, how may month
and how many days are completed. So please explain me


Mohamed Mohiddin
Officer
__________________
Mohamed Mohiddin
Officer
 
Old July 29th, 2005, 08:01 AM
Authorized User
 
Join Date: Jun 2004
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Default

days ==> DateDiff("d",[DOE],[DOR])
weeks ==> DateDiff("w",[DOE],[DOR])
months ==> DateDiff("m",[DOE],[DOR])
years ==> DateDiff("yyyy",[DOE],[DOR])

"Life is a Database"
 
Old July 29th, 2005, 11:56 AM
Authorized User
 
Join Date: Dec 2003
Posts: 63
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi sdilucca
thanks for your replay but i want if days>30 month should one month and month>12 year should add one year like below i given manualy format
                      completed days month year
 DOE=15/05/1975
 DOR=29/07/2005
remaining days,month,year 16 00 00
                                  00 07 00
1976 to 2004 00 00 28
01/01/2005 to 29/07/2005 29 06 00
                                  --------------
          Total 45 13 28
if days >30 45-30 and month shold come 13+1
and month >12 14-12 and year should add one
like 28+1
so completed days month years
              15 02 29
will come if above example how should i write the
function and code
thanks once again

Mohamed Mohiddin
Officer
 
Old July 29th, 2005, 12:03 PM
Authorized User
 
Join Date: Jun 2004
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Default

are you using VBA in your database?

"Life is a Database"
 
Old July 29th, 2005, 01:08 PM
Authorized User
 
Join Date: Jun 2004
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Default

forget about VBA... I figured out the Query... What is the name of your TABLE and date FIELDS?

"Life is a Database"
 
Old July 29th, 2005, 03:32 PM
Authorized User
 
Join Date: Jun 2004
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Default

ok.... I will assume the following table and fields:
  Table1
  dte_Start
  dte_End

Here is the SQL code for the query:

SELECT Table1.dte_start, Table1.dte_end, Int((DateDiff("d",[dte_start],[dte_end]))/365.25) AS Years, Int(((DateDiff("d",[dte_start],[dte_end])/365.25-1)-Int((DateDiff("d",[dte_start],[dte_end])/365.25-1)))*12) AS Months, Int((((DateDiff("d",[dte_start],[dte_end])/365.25-1)-Int((DateDiff("d",[dte_start],[dte_end])/365.25-1)))*12-Int(((DateDiff("d",[dte_start],[dte_end])/365.25-1)-Int((DateDiff("d",[dte_start],[dte_end])/365.25-1)))*12))*30)+1 AS Days
FROM Table1;

Now just replace the table and fields with your specific names. Let me know how it works out.

"Life is a Database"





Similar Threads
Thread Thread Starter Forum Replies Last Post
Date Type checking NEO1976 XSLT 5 February 1st, 2007 10:37 AM
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
date type queries mohiddin52 Access 1 March 19th, 2004 03:05 PM





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