Results 1 to 7 of 7

Thread: Convert a number into Date

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2001
    Location
    Philippines
    Posts
    136

    Convert a number into Date

    Hello there,

    Does anybody knows how can I convert this no. (254) into its equivalent Month and days. Its actually 254 days of the year 2001. I want to Know how can I know its August 10,2001. (08/10/2001). Automatically using codes.

    Pls. help. its important.
    elbimbo

  2. #2
    Fanatic Member khalik_ash's Avatar
    Join Date
    Aug 2002
    Location
    Singapore
    Posts
    724
    use DateAdd function

    VB Code:
    1. msgbox DateAdd(d, 254,'08/10/2001')

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Oct 2001
    Location
    Philippines
    Posts
    136

    follow up

    Hi,

    What if I have no Idea that it is August 10. I just know that its 254 days of the year 2001. My calculation is wrong coz Feb is only 28 or 29 days. How about if its a leap year.

    Pls reply.
    elbimbo

  4. #4
    Fanatic Member khalik_ash's Avatar
    Join Date
    Aug 2002
    Location
    Singapore
    Posts
    724
    function takes care of leap year... but u should have a base date to add...

  5. #5
    The picture isn't missing BuggyProgrammer's Avatar
    Join Date
    Oct 2000
    Location
    Vancouver, Canada
    Posts
    5,217
    probably would be more like this:

    msgbox DateAdd("d", 253,"01/01/2001") 'the beginning of the year + 253 days (accounts for the first day of the year)
    Remember, if someone's post was not helpful, you can always rate their post negatively .

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Oct 2001
    Location
    Philippines
    Posts
    136
    Welllll....

    Your solution returns a one month advance.
    elbimbo

  7. #7
    New Member
    Join Date
    Aug 2002
    Posts
    2
    Hi There,

    Doing a little date math I found that
    253
    -31 for all of January
    222
    -28 for all of Feruary
    194
    -31 for all of March
    163
    -30 for all of April
    133
    -31 for all of May
    102
    -30 for all of June
    72
    -31 for all of July
    41
    -31 for all of August
    10
    = september 10

    Or alternatively
    Code:
    MsgBox DateDiff("d", "12/31/2000", "8/10/2001")
    Yeilds a result of 222

    Hope this helps,

    J

Posting Permissions

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



Click Here to Expand Forum to Full Width