Code for the exact age

Author Message
ip1000

  • Total Posts : 1
  • Scores: 0
  • Reward points : 0
  • Joined: 7/16/2007
  • Status: offline
Code for the exact age Thursday, July 19, 2007 7:33 AM (permalink)
0
The following code will calculate the exact age on users from a DDBB, but somehow it´s giving me back the total number of years just taking in consideration the year and not using the month or day to correct the age.
 
<%
Dim dtNow, dtY2K
dtNow = Date()
dtY2K = DateSerial((Recordset.Fields.Item("bornyear").Value), (Recordset.Fields.Item("bornmonth").Value), (RecordsetCV.Fields.Item("bornday").Value))
 
 
Dim iYearDifference
iYearDifference = DateDiff("yyyy", dtY2K, dtNow)
%>
<%Response.write""&iYearDifference&""%>
 
Any input on why it´s not using the month and day to find the YearDifference?
 
Thanks in advance,
 
Ignacio Francisco Penin
 
#1
    Country73

    • Total Posts : 754
    • Scores: 10
    • Reward points : 0
    • Status: offline
    RE: Code for the exact age Friday, July 20, 2007 12:40 AM (permalink)
    0
    DateDiff(interval, date1, date2 [,firstdayofweek [, firstweekofyear]])
  • interval      Required. String expression that is the interval you want to use to calculate the differences between date1 and date2.
  • date1, date2     Required. Date expressions. Two dates you want to use in the calculation.
  • firstdayofweek  Optional. Constant that specifies the day of the week. If not specified, Sunday is assumed. See Settings section for values.
  • firstweekofyear  Optional. Constant that specifies the first week of the year. If not specified, the first week is assumed to be the week in which January 1 occurs.
    Your line:

    iYearDifference = DateDiff("yyyy", dtY2K, dtNow)

    You are using the year to find the YearDifference
  •  
    #2

      Online Bookmarks Sharing: Share/Bookmark

      Jump to:

      Current active users

      There are 0 members and 1 guests.

      Icon Legend and Permission

      • New Messages
      • No New Messages
      • Hot Topic w/ New Messages
      • Hot Topic w/o New Messages
      • Locked w/ New Messages
      • Locked w/o New Messages
      • Read Message
      • Post New Thread
      • Reply to message
      • Post New Poll
      • Submit Vote
      • Post reward post
      • Delete my own posts
      • Delete my own threads
      • Rate post

      2000-2012 ASPPlayground.NET Forum Version 3.9