Results 1 to 4 of 4
  1. #1
    mkappess is offline Novice
    Windows XP Access 2000
    Join Date
    Aug 2014
    Posts
    2

    Build expression to calculate weeks of gestation in a pregnancy

    I need to build an expresssion to identify weeks and days of the duration of a pregnancy. If due date is = to 40 weeks, then I need an expression to identify due date ( 40 weeks identified by a specific date) minus delivery date to yield the gestational age of the newborn. Any ideas?
    I'm self taught in Access, please keep it simple. and if you can write out the expression for me that would be awesome!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    a form with text box of start date
    a box for due date. txtDue = dateadd("d",280,txtStart )
    a box for gest. calc txtGes = datediff("d", txtStart,txtDue)
    (d is for days, so divide by 7)

  3. #3
    mkappess is offline Novice
    Windows XP Access 2000
    Join Date
    Aug 2014
    Posts
    2

    Gest age

    Quote Originally Posted by ranman256 View Post
    a form with text box of start date
    a box for due date. txtDue = dateadd("d",280,txtStart )
    a box for gest. calc txtGes = datediff("d", txtStart,txtDue)
    (d is for days, so divide by 7)

    Thanks for replying.. .. since I don't know the actual start date of the pregnancy, I need to build an expression using the due date, (the due date= duedate - 280 (would be the approximate pregnancy start date). then I can use the rest of your expression. However, when the report is made, my boss is looking for a 'weeks + days" format. For example the gestation was 37+4 (37 weeks +4 days).Thats how they determine if the baby is premature, and we are tracking premature births. Do I just have to do that manually, or can Access do a weeks + days total?
    Thanks

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    You'd need a routine to break up the days/weeks...

    Code:
    Public Function ElapsedTime(ByVal pvDate1) As String
    Dim iMos As Integer, iDays As Integer, iHrs As Integer, iYrs As Integer, iWeeks As Integer
    Dim vElaps
    On Error GoTo errElaps
    Dim vNow As Date
    vNow = Now()
    iDays = Abs(DateDiff("d", pvDate1, vNow))
      If iDays > 365 Then
           iYrs = iDays / 365
           iDays = iDays - Int(iYrs * 365)
           
           vElaps = iYrs & " years "
       End If
       
      If iDays > 30 Then
           iMos = iDays \ 30
           iDays = iDays - Int(iMos * 30)
           
           vElaps = vElaps & iMos & " Months "
       End If
       
      If iDays > 7 Then
           iWeeks = iDays \ 7
           iDays = iDays - Int(iWeeks * 7)
           
           vElaps = vElaps & iWeeks & " weeks "
       End If
       
      
      If iDays >= 1 Then vElaps = vElaps & iDays & " days "
        'hours here
        
    errElaps:
    ElapsedTime = vElaps
    End Function

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 12
    Last Post: 04-16-2014, 07:26 AM
  2. Replies: 1
    Last Post: 03-13-2014, 03:02 PM
  3. Calculate last 4 weeks (Friday to Friday)
    By Astron2012 in forum Queries
    Replies: 2
    Last Post: 11-29-2013, 04:08 PM
  4. Replies: 3
    Last Post: 11-22-2011, 11:06 AM
  5. How to calculate number of weeks
    By FeatherDust in forum Queries
    Replies: 0
    Last Post: 09-18-2009, 02:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums