Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do you convert Bday into Date in VBA
I am trying to find a way to convert a persons birthday into their age in years with todays date. I know how to make this convresion usin Excel cells but I cannot figure it out using VBA. Please help -- postlp6 ----------------------------------------------------------------------- postlp60's Profile: http://www.excelforum.com/member.php...fo&userid=2553 View this thread: http://www.excelforum.com/showthread.php?threadid=38966 |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do you convert Bday into Date in VBA
Hi,
one way: Sub test() MsgBox DateDifY(DateSerial(1980, 7, 24), Date) End Sub Function DateDifY(Date1 As Date, Date2 As Date) As Long Dim y As Integer, m As Integer, d As Integer If Date1 Date2 Then DateDifY = -1 Else y = Year(Date2) - Year(Date1) m = Month(Date2) - Month(Date1) d = Day(Date2) - Day(Date1) If d < 0 Then m = m - 1 If m < 0 Then y = y - 1 DateDifY = y End If End Function -- HTH okaizawa postlp60 wrote: I am trying to find a way to convert a persons birthday into their age, in years with todays date. I know how to make this convresion using Excel cells but I cannot figure it out using VBA. Please help. |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do you convert Bday into Date in VBA
use datedif function. see help
-- remove $$$ from email addresss to send email ============= postlp60 wrote in message ... I am trying to find a way to convert a persons birthday into their age, in years with todays date. I know how to make this convresion using Excel cells but I cannot figure it out using VBA. Please help. -- postlp60 ------------------------------------------------------------------------ postlp60's Profile: http://www.excelforum.com/member.php...o&userid=25532 View this thread: http://www.excelforum.com/showthread...hreadid=389665 |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
How do you convert Bday into Date in VBA
Thank you for pointing me to the DateDiff function. That is what I wa looking for. Presto -- postlp6 ----------------------------------------------------------------------- postlp60's Profile: http://www.excelforum.com/member.php...fo&userid=2553 View this thread: http://www.excelforum.com/showthread.php?threadid=38966 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Why can't I convert Long date format to Short date | Excel Discussion (Misc queries) | |||
How do I convert US date with 12hr format to European date 24hr | Excel Discussion (Misc queries) | |||
How to convert Gregorian date into Hijri Date in Excel 2007? | Excel Discussion (Misc queries) | |||
Convert a julian gregorian date code into a regular date | Excel Worksheet Functions | |||
how to convert julian date to regular calendar date | Excel Worksheet Functions |