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

    Days360 module with rounding

    Hello,
    I have the following module to replicate Days360:


    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

    Int or -Int rounds too far down or up

    I want this to round as would ROUND(DAYS360(V7,X7)/30,0, where 45 days between two dates would count as 1 month and 46 days and greater would count as 2 months, any suggestions?

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,428
    use the backslash?

    ?40\46
    0
    ?45\46
    0
    ?50\46
    1
    ?150\46
    3


    so the calculation might be

    iif(myvalue\46,2,1)

    or simply

    iif(myvalue<=45,1,2)

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

Similar Threads

  1. Days360 versus DatedIf versusDateDiff
    By smg in forum Queries
    Replies: 9
    Last Post: 08-20-2020, 10:27 AM
  2. Replies: 1
    Last Post: 06-07-2018, 08:05 AM
  3. Rounding up
    By UT227 in forum Queries
    Replies: 5
    Last Post: 07-18-2017, 10:35 AM
  4. class module vs regular module
    By Madmax in forum Modules
    Replies: 1
    Last Post: 05-01-2012, 03:44 PM
  5. Replies: 4
    Last Post: 05-16-2011, 04:58 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