Access ceiling function

Searched for it, no luck.

Can someone tell me how to create a ceiling function in MS access that behaves the same as in excel?

+3
source share
5 answers

You can add a link to the Microsoft Excel object library and use Excel.WorksheetFunction.Ceiling

+1
source

This answer uses VBA for access, and it is obtained from http://www.tek-tips.com/faqs.cfm?fid=5031 :

Public Function Ceiling(ByVal X As Double, Optional ByVal Factor As Double = 1) As Double
    ' X is the value you want to round
    ' Factor is the optional multiple to which you want to round, defaulting to 1
    Ceiling = (Int(X / Factor) - (X / Factor - Int(X / Factor) > 0)) * Factor
End Function

Note that this answer is mathematically correct for negative X. See http://en.wikipedia.org/wiki/Floor_and_ceiling_functions#Spreadsheet_software for background.

+8

Int() Floor(), Ceiling :   -INT (-x)

+8

, , . , VBA, Microsoft Excel:

Public Function Ceiling(Value As Double, Significance As Double) As Double
    Ceiling = Excel.WorksheetFunction.Ceiling(Value, Significance)
End Function

, :

SELECT Ceiling(([WorkTimes]![EndTime]-[WorkTimes]![BeginTime])*24,0.25) AS BillableTime
FROM WorkTimes;
+2

Access , VB.NET

Public Function Ceiling(ByVal value As Double, ByVal factor As Double) As Double
    Return Math.Ceiling(value / factor) * factor
End Function

#

public double Ceiling(double value, double factor)
{
    return Math.Ceiling(value / factor) * factor;
}

, , Google , .Net. , , .

-1

Source: https://habr.com/ru/post/1723552/


All Articles