{"title":"System.Date2DWY(Date, Integer) Method","url":"https://jonas-paprotka.de/docs/dev-itpro/developer/methods-auto/system/system-date2dwy-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-date2dwy-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-date2dwy-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":"Gets the day of the week, week number, or year of a Date Data Type.","date":"2026-10-01","meta":{"topic":"reference"},"outline":[{"level":1,"title":"System.Date2DWY(Date, Integer) Method","slug":"systemdate2dwydate-integer-method","at":0,"chars":2484},{"level":2,"title":"Syntax","slug":"syntax","at":168,"chars":151},{"level":2,"title":"Parameters","slug":"parameters","at":319,"chars":322},{"level":2,"title":"Return Value","slug":"return-value","at":641,"chars":111},{"level":2,"title":"Remarks","slug":"remarks","at":752,"chars":680},{"level":2,"title":"Example","slug":"example","at":1432,"chars":918},{"level":2,"title":"Related information","slug":"related-information","at":2350,"chars":134}],"text":"# System.Date2DWY(Date, Integer) Method\n> Version: _Available or changed with runtime version 1.0._\nGets the day of the week, week number, or year of a Date Data Type.\n## Syntax\n```al\nNumber :=   System.Date2DWY(Date: Date, Value: Integer)\n```\n> NOTE\n> This method can be invoked without specifying the data type name.\n## Parameters\nDate\nType: ../date/date-data-type\nThe input date.\nValue\nType: ../integer/integer-data-type\nSpecifies what the function returns. The valid options are 1, 2, and 3.\n The value 1 corresponds to day of the week (1-7, Monday = 1).\n The value 2 corresponds to week number (1-53).\n The value 3 corresponds to year.\n## Return Value\nNumber\nType: ../integer/integer-data-type\nThe resulting day of the week, week number, or year.\n## Remarks\nWhen the input date to the Date2DWY method is in a week that spans two years, the Date2DWY method computes the output year as the year that has the most days. For example, the input date is 010114. This date is in a week that starts on Monday, December 29, 2013, and ends Sunday, January 4, 2014. The week has three days in 2013 and four days in 2014. So the output year is 2014.\n> IMPORTANT\n> Date2DWY always uses the ISO week-numbering year scheme for the week, regardless of the server or device configuration. This means that week 01 of a year is the week that includes the first Thursday of the Gregorian year. Or in other words, the week that includes 4 January.\n## Example\nThis example shows a special case that occurs when you use the Date2DWY method in a week that spans two years.\n```al\nvar\n    InputDate: Date;\n    DayOfWeek: Integer;\n    WeekNumber: Integer;\n    Year: Integer;\n    Text000: Label 'The date %1 corresponds to:\\\\';\n    Text001: Label 'The day of the week: %2\\\\';\n    Text002: Label 'The week number: %3\\\\';\n    Text003: Label 'The year: %4';\nbegin\n    InputDate := 20140101D;\n    DayOfWeek := Date2DWY(InputDate, 1);\n    WeekNumber := Date2DWY(InputDate, 2);\n    Year := Date2DWY(InputDate, 3);\n    Message(Text000 + Text001 + Text002 + Text003, InputDate, DayOfWeek, WeekNumber, Year);\nend;\n```\nThe message window displays the following information:\nThe date 01/01/14 corresponds to:\nThe day of the week: 4\nThe week number: 1\nThe year: 2014\nThis example shows that the date 01/01/14 is regarded as day number 4 \\(Thursday\\) in week number 1 in the year 2014.\n## Related information\nsystem-data-type\nGet Started with AL<../../devenv-get-started>\nDeveloping Extensions<../../devenv-dev-overview>"}