Results 1 to 9 of 9
  1. #1
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Day of month as number (2002)

    Hi,

    God I hate working with Dates. I need to have the day of the month as just a number. IE =now() would yield 9/2/2005. If I format it as dd I get 02, but if I then multiply this against a value its acutally multiplied agains the date. I need to be able to take what day it is in the month ( in this instance 2) to multiply in the forumla.

    Thanks,
    Leesha

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Day of month as number (2002)

    Use the Day function <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    For example: for today, the 2nd of September, 2005:

    Day(Date()) returns 2
    Month(Date()) returns 9
    Year(Date()) returns 2005

  3. #3
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Day of month as number (2002)

    OMG, it can't be that easy!! I've used Month and year but never Day!!! I'm such an idiot!

    Thanks,
    Leesha

  4. #4
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Day of month as number (2002)

    Back again! OK, so how do I find the day of the year it is? As in today would be the ??? day of 2005.

    Thanks,
    Leesha

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Day of month as number (2002)

    Legare's expression will do what you want with a slight modification:
    <code>
    Date()-DateSerial(Year(Date()),1,0)
    </code>
    (Legare's version counts the number of days since January 1st, that is 1 less than the day number).

    Another possibility is
    <code>
    DatePart("y",Date())
    </code>
    or
    <code>
    Val(Format(Date(),"y")
    </code>
    Format returns a text value, as you have found, but Val converts the result into a number again.

  6. #6
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Day of month as number (2002)

    I am not sure of the exact syntax and function names in Access, but it would be something like this:

    <code>
    Date()-DateSerial(Year(Date()),1,0)
    </code>
    Legare Coleman

  7. #7
    Uranium Lounger
    Join Date
    Jan 2001
    Location
    South Carolina, USA
    Posts
    7,295
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Day of month as number (2002)

    <img src=/S/blush.gif border=0 alt=blush width=15 height=15> More air code.


    Thanks, I fixed my post.
    Legare Coleman

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Day of month as number (2002)

    Your basic <img src=/S/pun.gif border=0 alt=pun width=22 height=18> idea was correct <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    (The date functions are standard VBA, they are not application-dependent)

  9. #9
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: Day of month as number (2002)

    Don't brag Leesha.

    Just remember, we all have to learn.

Posting Permissions

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