# Thread: Enter Date of birth in text box

1. ## Enter Date of birth in text box

Hi,

I need to enter perticular age like 28.i need to enter date of birth in text box(MM/DD/YYYY) compare with system date.

2. ## Re: Enter Date of birth in text box

sMonth = Month(Date)
sDay = Day(Date)
If Len(sMonth) = 1 Then sMonth = "0" &amp; sMonth
If Len(sDay) = 1 Then sDay = "0" &amp; sDay

sDate = sMonth &amp; "/" &amp; sDay &amp; "/" &amp; Year(date) - 28

you can take the sDate to set the text box

3. ## Re: Enter Date of birth in text box

[ QUOTE ]
sMonth = Month(Date)
sDay = Day(Date)
If Len(sMonth) = 1 Then sMonth = "0" &amp; sMonth
If Len(sDay) = 1 Then sDay = "0" &amp; sDay

sDate = sMonth &amp; "/" &amp; sDay &amp; "/" &amp; Year(date) - 28

you can take the sDate to set the text box

[/ QUOTE ]

4. ## Re: Enter Date of birth in text box

Hi TringTring,

Sub Practise()
b = Date ' 6/22/2011
c = Split(b, "/")
c(1) = "30" ' enter the Age what u want in a text box field
strFinal = Join(c, "/")
MsgBox strFinal
End Sub

Thanks,
Chandra.

5. ## Re: Enter Date of birth in text box

None of the above code fragments will give accurate results in all circumstances (taking care of leap years for instance).

I suggest :
<font class="small">Code:</font><hr /><pre>
Age = 28
MsgBox sDate
</pre><hr />

6. ## Re: Enter Date of birth in text box

Test before you post. what you are doing is changing the date. final output based on your code will be "6/30/2011" [img]/images/graemlins/smile.gif[/img]

[ QUOTE ]
Hi TringTring,

Sub Practise()
b = Date ' 6/22/2011
c = Split(b, "/")
c(1) = "30" ' enter the Age what u want in a text box field
strFinal = Join(c, "/")
MsgBox strFinal
End Sub

Thanks,
Chandra.

[/ QUOTE ] [img]/images/graemlins/ooo.gif[/img] [img]/images/graemlins/cool.gif[/img]

7. ## Re: Enter Date of birth in text box

tringtring,
let me know how you manage to work out someone's date of birth when all you have is today's date and their age in years.
I'll see I can get us a TV show if you can do it! :-)

Unless perhaps you were after the opposite - given today's date and their date of birth, how many years old are they?

8. ## Re: Enter Date of birth in text box

Hello Antoney,

The question is "to enter a particular age like 28 or what ever the date in the format like MM/DD/YYYY" U mean the below code is wrong ? If it is wrong, please post the solution, I tested before posting into this forum ok naaa.

Sub Practise()
b = Date ' 6/22/2011
c = Split(b, "/")
c(1) = "30" ' enter the Age what u want in a text box field
strFinal = Join(c, "/")
MsgBox strFinal
End Sub

Thanks,
Chandra.

9. ## Re: Enter Date of birth in text box

One thing!!

U just said 28 Years!! It can be anything from Jan 1 to June 22. How do u wish to get the date and month, i think year you could calculate with year part in sysdate - 28.

10. ## Re: Enter Date of birth in text box

Good solution Christian.

Page 1 of 2 12 Last

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•

vBulletin Optimisation provided by vB Optimise v2.6.0 Beta 4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.