Results 1 to 4 of 4
  1. #1
    smg is offline Competent Performer
    Windows XP Access 2010 64bit
    Join Date
    Apr 2019
    Posts
    115

    how to use GetMonths360 function in different query with different date fields

    I am using the following function and it is working! Now, I need to use it in another query for two different date fields TerminationDate and PeriodToDate. I tried to copy it and call it GetMonths360A and change the date fields, but it seemed to mess up the original function/query so I am asking for advice on how to accomplish this. Thanks.



    Public Function GetMonths360(TimesheetDate As Date, ReleaseDate As Date)
    GetMonths360 = ((Year([TimesheetDate]) - Year([ReleaseDate])) - 1) * 360 + ((12 - Month([ReleaseDate])) * 30) + (30 - Day([ReleaseDate])) + ((Month([TimesheetDate]) - 1) * 30) + (Day([TimesheetDate]))
    GetMonths360 = -Int(-GetMonths360 / 30)
    End Function

  2. #2
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    8,567
    is this the same issue as you posted here?

    https://www.accessforums.net/showthread.php?t=81518

    You should have continued the same thread - then those that have already responded would likely get an email and might come back to help. This way, they may not see it at all. Besides, it's really the same problem.
    - "doesn't work" doesn't help. Implement changes in copies of your database.
    Iím telling everyone it's good to eat dried grapes. Itís all about raisin awareness.

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    21,691
    When you call it you pass it two dates. It doesn't care what fields those dates are from, it will make its calculation. Have you tried calling it:

    GetMonths360(TerminationDate, PeriodToDate)

    In any case, creating a new function with a different name shouldn't affect the first one at all.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    smg is offline Competent Performer
    Windows XP Access 2010 64bit
    Join Date
    Apr 2019
    Posts
    115
    Micron, In other threads when someone asks a new question, I've seen responses where it says it should be a new post. Since it is a slightly different question, I used new post. I was hoping those that responded would see it, so I will try that in the future.
    Pbaldy, I will try calling it.
    Thanks to both of you

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

Similar Threads

  1. Replies: 14
    Last Post: 08-20-2020, 10:25 AM
  2. Replies: 4
    Last Post: 04-22-2015, 05:50 AM
  3. Date() function not working in query
    By riggsdp in forum Queries
    Replies: 8
    Last Post: 02-05-2015, 02:33 PM
  4. Replies: 5
    Last Post: 12-12-2013, 12:14 PM
  5. Replies: 12
    Last Post: 05-07-2012, 12:41 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 - Senior Forums