Alpha Video Training
Results 1 to 8 of 8

Thread: Need help with Date conversions

  1. #1
    Member
    Real Name
    Dennis Alcorn
    Join Date
    Oct 2006
    Posts
    1

    Default Need help with Date conversions

    Hi, I am a new user to this software and I have put together a database for data collection. I work for a fire department and I am in charge of collecting all the information on our calls.


    I have a medical database and I would like to know how I can subtact a persons date of birth which is a field on its own from the incident date which I enter manually. I need this to display in just years. I would like to be able to just enter the patients date of birth in one field and the next field on my database is age. I would like this program to just auto enter the age from date of birth minus the incident date. I dont know where to begin to do this, so please help


    Thanks very much

    Dennis

  2. #2
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Need help with Date conversions

    All depends on what you really mean by subtracting one date from another. If you want to calculate a number of years based on specific dates in two spearate years.

    Code:
    d1 = {12/15/1975}
    d2 = {04/22/1999}
    ? d2 - d1
    = 8529.000000
    
    ? (d2 - d1)/365
    = 23.367123
    If you want to know the difference in the year numbers.

    Code:
    ? year(d1)
    = 1975.000000
    
    ? year(d2)
    = 1999.000000
    
    ? year(d2)-year(d1)
    = 24.000000
    If you want to know the age of a person given a specific date.

    Code:
    d1 = {12/15/1975}
    d2 = {04/22/1999}
    
    ? age(d1,d2)
    = 23.000000
    Any of these calculations (d2 - d1)/365, year(d2)-year(d1), age(d1,d2) could be used as the defined expression for a calculated field in a table.

  3. #3
    "Certified" Alphaholic
    Real Name
    Louis Nickerson
    Join Date
    Aug 2002
    Posts
    1,039

    Default Re: Need help with Date conversions

    Dennis,

    From the Interactive Window...

    ?age({02/14/62},{10/02/06})
    = 44

    Hope this helps!

    Louis

  4. #4
    "Certified" Alphaholic Rich Hartnett's Avatar
    Real Name
    Richard Hartnett
    Join Date
    Nov 2002
    Location
    Bowie, MD
    Posts
    1,464

    Default Re: Need help with Date conversions

    Based on the above posts, I'm using the following to obtain the correct AGE from the person's DOB, based on the Date Reported:

    AGE(DOB,DATEREP)

    It works fine, except when there is no DOB. In those cases it is displaying the a negative number, which of course is correct.

    Is there any way I can prevent it from displaying a number if the answer is zero or in the negatives?

  5. #5
    VAR davej's Avatar
    Real Name
    Dave Jampole
    Join Date
    Apr 2000
    Location
    Haughton, LA ( just east of Shreveport, Louisiana)
    Posts
    2,524

    Default Re: Need help with Date conversions

    Rich,

    Try a logic expression like:
    if(AGE(DOB,DATEREP)<=0,"",AGE(DOB,DATEREP))

    Dave
    Dave Jampole
    www.customalpha.com

    Women and cats will do whatever they want. The sooner men and dogs realize that, the happier they will be.


  6. #6
    "Certified" Alphaholic Rich Hartnett's Avatar
    Real Name
    Richard Hartnett
    Join Date
    Nov 2002
    Location
    Bowie, MD
    Posts
    1,464

    Default Re: Need help with Date conversions

    Thanks for the reply Dave, but I'm getting a message that the equation does not result in a numeric value.

  7. #7
    "Certified" Alphaholic Stan Mathews's Avatar
    Real Name
    Stan Mathews
    Join Date
    Apr 2000
    Location
    Bowling Green, KY
    Posts
    25,119

    Default Re: Need help with Date conversions

    Quote Originally Posted by davej View Post
    Rich,

    Try a logic expression like:
    if(AGE(DOB,DATEREP)<=0,"",AGE(DOB,DATEREP))

    Dave
    Since age returns a number I don't think that would work. You could use

    if(AGE(DOB,DATEREP)<=0,0,AGE(DOB,DATEREP))

    and set the field format to "1234567.78 (blank if zero)" in the object properties or


    if(AGE(DOB,DATEREP)<=0,"",alltrim(str(AGE(DOB,DATEREP))))

  8. #8
    "Certified" Alphaholic Rich Hartnett's Avatar
    Real Name
    Richard Hartnett
    Join Date
    Nov 2002
    Location
    Bowie, MD
    Posts
    1,464

    Default Re: Need help with Date conversions

    Works like a champ!

    Thanks Stan and Dave for the assistance.

Similar Threads

  1. Replies: 0
    Last Post: 06-22-2006, 05:17 AM
  2. add_bus_days(month_start(date()),1) Ending Date Results?
    By reedorbs in forum Alpha Five Version 7
    Replies: 11
    Last Post: 05-18-2006, 01:39 PM
  3. Start date & Week ending date..
    By rae4sp in forum Alpha Five Version 6
    Replies: 2
    Last Post: 09-22-2005, 11:29 AM
  4. Metric - Imperial Calculated Conversions
    By David Priest in forum Alpha Five Version 5
    Replies: 3
    Last Post: 03-11-2004, 10:27 AM
  5. Date Conversions
    By Sue Pellant in forum Alpha Five Version 4
    Replies: 5
    Last Post: 02-10-2001, 04:10 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •