{"title":"System.RoundDateTime(DateTime [, BigInteger] [, Text]) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/system/system-rounddatetime-method/","by":"JOP-AL","license":"Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/system/system-rounddatetime-method, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact.","credit":"Microsoft Corporation, CC BY 4.0","origin":"https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/methods-auto/system/system-rounddatetime-method","source":{"name":"Business Central developer and IT pro docs","repo":"https://github.com/MicrosoftDocs/dynamics365smb-devitpro-pb","commit":"828b6ee72fcd75755627cd6011f3d20899217ab2","date":"2026-11-19"},"checked":"2026-11-19","description":"Rounds a DateTime.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"System.RoundDateTime(DateTime [, BigInteger] [, Text]) Method","slug":"systemrounddatetimedatetime-biginteger-text-method","at":0,"chars":2819},{"level":2,"title":"Syntax","slug":"syntax","at":143,"chars":199},{"level":2,"title":"Parameters","slug":"parameters","at":342,"chars":704},{"level":2,"title":"Return Value","slug":"return-value","at":1046,"chars":85},{"level":2,"title":"Remarks","slug":"remarks","at":1131,"chars":846},{"level":2,"title":"Example","slug":"example","at":1977,"chars":708},{"level":2,"title":"Related information","slug":"related-information","at":2685,"chars":134}],"text":"# System.RoundDateTime(DateTime [, BigInteger] [, Text]) Method\n> Version: _Available or changed with runtime version 1.0._\nRounds a DateTime.\n## Syntax\n```al\nNewDatetime :=   System.RoundDateTime(Datetime: DateTime [, Precision: BigInteger] [, Direction: Text])\n```\n> NOTE\n> This method can be invoked without specifying the data type name.\n## Parameters\nDatetime\nType: ../datetime/datetime-data-type\nThe DateTime that you want to round.\n*[Optional] Precision*\nType: ../biginteger/biginteger-data-type\nThis optional parameter determines the precision used when rounding. The default value is 1000, which rounds to the nearest second. You can only use positive BigIntegers.\n*[Optional] Direction*\nType: ../text/text-data-type\nThis optional parameter specifies how to round the DateTime. The default rounding method is '='. You can change the method by using the following options:\n '=' rounds up or down to the nearest value (default). Values of 5 or greater are rounded up. Values less than 5 are rounded down.\n '\\>' rounds up\n '\\<' rounds down\n## Return Value\nNewDatetime\nType: ../datetime/datetime-data-type\nThe rounded result.\n## Remarks\nA variable of type DateTime is stored as a 64 bit integer. The integer value is the number of milliseconds since year 0. When you call RoundDateTime, the DateTime integer value is rounded as a numeric variable.\nIf you use 1 for the Precision parameter, then the resulting DateTime is rounded to the nearest millisecond. If you use 1000 for the Precision parameter, which is the default value, then the resulting DateTime will be rounded to the nearest second.\nWe recommend that you do not use a value greater than 60*60*1000, which is the number of milliseconds in an hour, for the Precision parameter. The Regional and Language Options in Windows affect how the hour and date parts of a DateTime are rounded. To display a DateTime in a specific format, we recommend that you use the Format method instead of the RoundDateTime method.\n## Example\nThis example shows how to use the RoundDateTime method to round to the nearest second.\n```al\nvar\n    Text000: Label 'RoundDateTime(%1, %2) returns %3.';\nbegin\n    DateToRound := 20081127D;\n    TimeToRound := 093524.567T;\n    DateTimeToRound := CreateDateTime(DateToRound, TimeToRound);\n    Precision := 1000L;\n    FormatString := '<Month,2>/<Day,2>/<Year> <Hours24,2>:<Minutes,2>:<Seconds,2>.<Thousands,3>';\n    Result := RoundDateTime(DateTimeToRound, Precision);\n    Message(TEXT000, Format(DateTimeToRound,0,FormatString), Precision, Format(Result,0,FormatString));\nend;\n```\nThe message window displays the following:\nRoundDateTime\\(11/27/08 09:35:24.567, 1000\\) returns 11/27/08 09:35:25.000.\n## Related information\nsystem-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}