Results 1 to 9 of 9
  1. #1
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    return dateserial... (2000)

    Sub uno()

    mese = "01"
    anno = "2008"

    mese1 = "01"
    anno2 = "2008"

    test = DateSerial(mese & ",/" & anno)

    End Sub


    how to return datesrial in test???
    Naturally have error in:
    test = DateSerial(mese & ",/" & anno)

    In effect i want the dateserial of the joint month/year

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: return dateserial... (2000)

    DateSerial requires 3 arguments - year, month and day. If you just want a string, you can just use:
    <code>test = mese & "/" & anno</code>
    If you want an actual date, you need to provide a day.
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: return dateserial... (2000)

    You don't have the DAY. Try something like:
    test = DateSerial(anno,mese,1)

    For the first day of the month/year. (note dateserial takes year, month, day and thy should be numbers not text...)

    Steve

  4. #4
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: return dateserial... (2000)

    Try the following
    <div style="width: 100%; background-color: #FFFFFF;"><code><font color=black><font color=blue>Sub</font color=blue> uno()

    MESE = "1"
    ANNO = "2008"

    mese1 = "01"
    anno2 = "2008"
    dd = 25
    test = DateSerial(ANNO, MESE, dd)
    <font color=blue>End</font color=blue> <font color=blue>Sub</font color=blue>


    </font color=black></code></div hiblock>
    Regards
    Don

  5. #5
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: return dateserial... (2000)

    Good!
    But i dont see in TEST the number, but only date...
    I want in TEST=3948

  6. #6
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: return dateserial... (2000)

    Sal
    I have seen posts in the past advising you to use Option Explicit. To do so in this instance, you would have been prompted to dimension Test. If you add the declaration " Dim test As Long ", you will get what you are after.
    Regards
    Don

  7. #7
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: return dateserial... (2000)

    I assume you mean 394<font color=red>4</font color=red>8 which is January 1, 2008. As Don indicted you must format the variable as a number, otherwise it will presume it is a date since you putting in a date.

    Steve

  8. #8
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: return dateserial... (2000)

    now work.
    Tks.

  9. #9
    Gold Lounger
    Join Date
    Jan 2004
    Location
    Italy
    Posts
    3,245
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: return dateserial... (2000)

    yes. sorry 39448 is ok...
    Lost a "4";-)

Posting Permissions

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