Solved

Calculate the age and corrected age of prenatal patients

Posted on 2011-03-04
5
598 Views
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.
0
Comment
Question by:Steynsk
5 Comments
 
LVL 77

Expert Comment

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


280- (Zwangerschapsduur_weken*7) - Zwangerschapsduur_dagen
0
 
LVL 11

Accepted Solution

by:
Swindle earned 500 total points
ID: 35037779

SELECT DATEDIFF(DAY, CONVERT(DATETIME, geboortedatum), GETDATE()) as Days_Old,
    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
   
0
 
LVL 4

Expert Comment

by:Amgad_Consulting_Co
ID: 35037783
Hi,

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
0
 
LVL 1

Author Comment

by:Steynsk
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?

Thanks
0
 
LVL 1

Author Closing Comment

by:Steynsk
ID: 35037970
Dear Swindle,

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

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

778 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