Results 1 to 3 of 3
  1. #1
    tagteam is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    501

    DateSerial not working

    I am trying to get the first day of the month after the average of a group of dates. I am able to accurately get the Average Date. Then I use an unbound field to get the year by using Year([avgdate]) and get the month by Month([avgdate]) and those both work and I get the correct year and month.

    However, when I use =DateSerial([AvgYear],[AvgMonth],1) it doesn't work.



    For example, if I have an average date of 1/8/2025 in AvgYear I get 2025 and in AvgMonth I get 1. I try to use DateSerial to get 1/1/2025 so I can then just add 1 month but I get 12/1/1899

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,570
    Code:
    yy=2025
    mm=1
    ? dateserial(yy,mm,1)
    01/01/2025 
    dt=#01/08/2025#
    ? year(dt)
     2025 
    ? month(dt)
     1 
    ? dateserial(year(dt),month(dt),1)
    01/01/2025
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    tagteam is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2013
    Posts
    501
    Sorry, for some reason I accidentally had this in the Default Value and it would not work. When I moved the above the the ControlSource it worked fine.

    using =Year([AverageDOA]) to get year and =Month([AverageDOA])+1 to get month and =DateSerial([AvgYear],[AVGMonth],1) to get new date

Please reply to this thread with any new information or opinions.

Similar Threads

  1. DateAdd DateSerial
    By aellistechsupport in forum Queries
    Replies: 2
    Last Post: 04-30-2014, 05:09 PM
  2. Dateserial and datetime
    By webisti in forum Access
    Replies: 1
    Last Post: 06-17-2013, 11:31 AM
  3. Problem with a DateSerial Function
    By razkowski in forum Queries
    Replies: 1
    Last Post: 01-31-2013, 04:47 PM
  4. DateSerial Format
    By venu_resoju in forum Reports
    Replies: 4
    Last Post: 01-19-2013, 02:20 AM
  5. Replies: 2
    Last Post: 08-07-2012, 02:02 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums