473,386 Members | 1,752 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,386 software developers and data experts.

Age difference in access 2007

Im trying to write a short data base to figure age diffence in new borns from their projected date of birth to their actual date of birth. I need the answer to be in weeks and days. Thanks in advance for any help.
Aug 30 '10 #1
3 1659
mwasif
802 Expert 512MB
Moved to MS Access forum.
Sep 2 '10 #2
TheSmileyCoder
2,322 Expert Mod 2GB
I wrote you some code which will calculate the difference and give the result as a string.

Expand|Select|Wrap|Line Numbers
  1. Public Function AgeDiff(dt_ActualBirth As Date, dt_ProjectedBirth As Date) As String
  2.     'Code by TheSmileyOne
  3.     'Calculates the difference between two input dates, and returns the answer as a string
  4.  
  5.     'Init variables
  6.         Dim intDays As Integer
  7.         Dim intWeeks As Integer
  8.         Dim bPremature As Boolean
  9.  
  10.     'Get total number of days
  11.         intDays = DateDiff("d", dt_ProjectedBirth, dt_ActualBirth)
  12.  
  13.     'Is baby premature?
  14.         bPremature = (intDays < 0)
  15.  
  16.     'Get number of weeks
  17.         intWeeks = Int(Abs(intDays) / 7)
  18.  
  19.     'Get number of remaining days
  20.         intDays = Abs(intDays) - intWeeks * 7
  21.     AgeDiff = intWeeks & " weeks and " & intDays & " days"
  22.     'Return result
  23.     If bPremature Then
  24.         AgeDiff = AgeDiff & " early"
  25.         Else
  26.         AgeDiff = AgeDiff & " late"
  27.     End If
  28.  
  29. End Function
Output looks like:
Expand|Select|Wrap|Line Numbers
  1. 2 weeks and 0 days late
  2. 1 weeks and 3 days early
Sep 2 '10 #3
Thanks SmileyOne.
Sep 2 '10 #4

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

Similar topics

27
by: Wayne | last post by:
I've been clicking around Access 2007 Beta 2 and can't see the custom menu bar designer. Is it in the beta? Maybe I'm blind. The question that comes to mind is: Will custom menu bars be the same...
49
by: Allen Browne | last post by:
If you are looking for opinon on what's useful in Access 2007, there's a new article at: http://allenbrowne.com/Access2007.html Covers what's good (useful features), what's mixed (good and bad),...
1
prn
by: prn | last post by:
Hi folks, I'm relatively new to Access, but I seem to have drawn the short straw, so I have the assignment for my workplace of looking for problems/inconsistencies in migrating applications to...
17
by: Neil | last post by:
A client of mine likes some of the new bells and whistles in Access 2007, and is thinking about converting our A03 format MDB to an A07 format file. However, while some of the users have A07, many...
16
by: Neil | last post by:
I posted a few days ago that it seems to me that the Access 2007 rich text feature does not support: a) full text justification; b) programmatic manipulation. I was hoping that someone might...
0
by: SpaceMarine | last post by:
hello, does anyone know how to convert Access 2000 .MDA files to the Access 2007 equivalent? ive been able to convert .MDB files to .ACCDB, but not MDAs. im new to Access, and have been asked...
10
by: Arno R | last post by:
Hi all, So I bought a new laptop 10 days ago to test my apps with Vista. (home premium) Apparently Office 2007 is pre-installed. (a time limited but complete test version, no SP1) So I take the...
1
by: myipmike | last post by:
Hi there, I have an app that produces labels and which runs fine under Access 2000, 2002 and 2003. The compiled 2002 .mde version runs fine under Access 2007 but only sometimes ! i.e. under XP...
10
by: Lou O | last post by:
I have been using Access 2007 for a number of months and have successfully deployed ACCDR files on many client machines. The client machines have the "free" Access runtime version installed. I...
1
by: BL3WC | last post by:
Hi, I'd created a MDE under Access 2003. It is now under testing stage. Some of the users will use Access 2003 runtime and some will use Access 2007 runtime to run this MDE. I installed the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
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
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
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
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...

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.