SPONSORS:






User Tag List

Thanks Thanks:  0
Likes Likes:  0
Dislikes Dislikes:  0
Results 1 to 4 of 4
  1. #1
    Junior Member
    Join Date
    Mar 2010
    Posts
    3
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Generating a random date of birth

    Hi,

    I need to generate a random DOB for someone who is younger than 70 but over 18, Could anybody suggest how i might do it? I played around with RandomNumber but that obviously doesn't take into account the different days in different months.

    Hope that makes sense,

    Cheers.

  2. #2
    Moderator
    Join Date
    Jul 2005
    Location
    Delhi
    Posts
    15,575
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    7 Thread(s)
    Total Downloaded
    0

    Re: Generating a random date of birth

    Well should not be a issue. Have 1 array of maxValues

    maxDate = Array(31,28,31,30,31,30,31,31,30,31,30,31)

    randYear = RandomNumber.Value(Year(now)-70, year(now) - 18)
    randMonth = RandomNumber.Value(1,12)
    randDay = RandomNumber.Value(1, maxDate(randMonth)

    Msgbox randDay & "/" & randMonth & "/" & randYear

  3. #3
    Senior Member
    Join Date
    Jun 2007
    Location
    Toronto, Canada
    Posts
    362
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Total Downloaded
    0

    Re: Generating a random date of birth

    [ QUOTE ]
    randMonth = RandomNumber.Value(1,12)

    [/ QUOTE ]

    Tarun..Shouldnt this be
    randMonth = RandomNumber.Value(0,11)

  4. #4
    Moderator
    Join Date
    Jul 2005
    Location
    Delhi
    Posts
    15,575
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    7 Thread(s)
    Total Downloaded
    0

    Re: Generating a random date of birth

    Well yes. or else we can do below

    maxDate = Array(0, 31,28,31,30,31,30,31,31,30,31,30,31)

 

 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Search Engine Optimisation provided by DragonByte SEO v2.0.36 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Resources saved on this page: MySQL 11.54%
vBulletin Optimisation provided by vB Optimise v2.6.4 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
User Alert System provided by Advanced User Tagging v3.2.8 (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
vBNominate (Lite) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Feedback Buttons provided by Advanced Post Thanks / Like (Pro) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
Username Changing provided by Username Change (Free) - vBulletin Mods & Addons Copyright © 2016 DragonByte Technologies Ltd.
BetaSoft Inc.
Digital Point modules: Sphinx-based search
All times are GMT -8. The time now is 01:36 AM.

Copyright BetaSoft Inc.