Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Calculate the age and corrected age of prenatal patients

Posted on 2011-03-04
Last Modified: 2012-05-11
Hi Experts,

I’ve got to calculate the age and corrected age of a selection of prenatal patients from our prenatal department.

The corrected age is the age a child would have if it would have been born after a full pregnancy of 280 day (40 weeks).

What do we know?

We do know the:

•      birth date (stored in a nvarchar field) name “geboortedatum”  format yyyy-mm-dd
•      pregnancy weeks (stored in a nvarchar field)  name “Zwangerschapsduur_weken” format example “27”
•      pregnancy days (stored in a nvarchar field)  name “Zwangerschapsduur_dagen” format example “4”

We need to know (based on the current date):

•      The current uncorrected age (based on the birth date) precise by the day.
•      The corrected age precise by the day.
•      The number of days between the uncorrected and corrected age.

Besides the points you will receive our hospitals gratitude for your contribution to public healthcare in the Netherlands.
Question by:Steynsk
LVL 77

Expert Comment

ID: 35037688
The number of days difference is just..

280- (Zwangerschapsduur_weken*7) - Zwangerschapsduur_dagen
LVL 11

Accepted Solution

Swindle earned 500 total points
ID: 35037779

    geboortedatum AS Uncorrected_Birth_Date,
    DATEADD(DAY, (280 - CONVERT(TINYINT, Zwangerschapsduur_weken) * 7 + CONVERT(TINYINT, Zwangerschapsduur_dagen)), geboortedatum ) Corrected_Birth_Date,
    280 - CONVERT(TINYINT, Zwangerschapsduur_weken) * 7 + CONVERT(TINYINT, Zwangerschapsduur_dagen) AS Days_Early

Expert Comment

ID: 35037783

I'm going to write some tips for you that might help:

1. to get current uncorrected age [Select datediff(day, birthdate, getdate()) from ...... ]

2. to get the corrected age:
   - get the start pregnancy date = birth_date - pregnancy days in sql ' set @birthdate = dateadd(d, birthdate , -1* pregnancy days)'
   - get the estimated_birth_date = start_date + 240 day in sql ' set @estbirth_date = dateadd(d, startdate,240)'
   - select @corrected_age = getdate()-estbirth_date

3. just subtract the two dates above.

- To get current date "today" use getdate()

- Date time functions help:http://msdn.microsoft.com/en-us/library/ms186724.aspx

Author Comment

ID: 35037788
Sorry Peter,

I'm used to do only simple select statements and don't understand.
Can you please give a more detaild discription what I should do?


Author Closing Comment

ID: 35037970
Dear Swindle,

This is exact what we were looking for. Thank you very much you helped us a great deal.

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Amazon RDS migrate to SQL Server 3 26
Syntax error with Dates where clause 10 47
SQL query and VBA 5 46
job schedule 8 19
Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

839 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question