Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 129
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Why can't I convert Long date format to Short date Jason Excel Discussion (Misc queries) 1 January 22nd 10 10:24 PM
How do I convert US date with 12hr format to European date 24hr Enda K Excel Discussion (Misc queries) 1 November 15th 09 09:59 AM
How to convert Gregorian date into Hijri Date in Excel 2007? Ahmed Excel Discussion (Misc queries) 2 February 6th 09 03:59 PM
Convert a julian gregorian date code into a regular date Robert Excel Worksheet Functions 3 June 13th 06 07:03 PM
how to convert julian date to regular calendar date Ron Excel Worksheet Functions 5 May 5th 05 11:05 PM


All times are GMT +1. The time now is 11:56 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"