Results 1 to 7 of 7
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Posts
    1,119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Date Part (Access 97)

    I am trying to extract the month and year from a date field using the following in a query:
    NewDate: DatePart("M",[DateCompleted]). This will extract the month but I would like to extract the year too. Can this be done?

  2. #2
    New Lounger
    Join Date
    Apr 2002
    Location
    Columbus, Ohio, USA
    Posts
    19
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date Part (Access 97)

    Linda: Try this for the year.

    YearDate: DatePart("yyyy",[DateCompleted]).

    HTH.

  3. #3
    Lounger
    Join Date
    Jun 2002
    Location
    Anderson, Indiana, USA
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date Part (Access 97)

    have you tried:NewDate: DatePart("M",[DateCompleted]) &" "& DatePart("YY",[DateCompleted])

  4. #4
    5 Star Lounger
    Join Date
    Jan 2001
    Posts
    1,119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date Part (Access 97)

    That works fine but I need Month and Year in the same field. Like this 11/2001. Can I concatenate?

  5. #5
    Lounger
    Join Date
    Jun 2002
    Location
    Anderson, Indiana, USA
    Posts
    37
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date Part (Access 97)

    you should be able to with & "/"& so use which one that work with &"/"&

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Date Part (Access 97)

    When you say "in the same field", does that mean you're actually storing this value in a table? If so, why? You can always use a format function or a custom display format to show the date in "mm/yyyy" format without have to do anything to the data itself.
    Charlotte

  7. #7
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Date Part (Access 97)

    use NewDate: format([DateCompleted],"m/yyyy")

    By changing the number of m's and y's you can change the format of the display.
    Regards
    John



Posting Permissions

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