{"id":2804,"date":"2011-06-07T16:00:00","date_gmt":"2011-06-07T14:00:00","guid":{"rendered":"https:\/\/ingmarverheij.com\/2011\/06\/business-objects-oracle-returns-wrong-day-of-week\/"},"modified":"2011-06-07T16:00:00","modified_gmt":"2011-06-07T14:00:00","slug":"business-objects-oracle-returns-wrong-day-of-week","status":"publish","type":"post","link":"https:\/\/ingmarverheij.com\/en\/business-objects-oracle-returns-wrong-day-of-week\/","title":{"rendered":"Business Objects (Oracle) returns wrong day of week"},"content":{"rendered":"<p><img loading=\"lazy\" decoding=\"async\" style=\"background-image: none; border-right-width: 0px; margin: 0px 5px 0px 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px\" title=\"Days of the week\" border=\"0\" alt=\"Days of the week\" align=\"left\" src=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2011\/06\/DaysOfWeek.jpg\" width=\"79\" height=\"108\" \/><\/p>\n<p>Business Objects (BO) is used to generate a report showing the schedule of employees. In the schedule the day of week is displayed as a header, which makes it easy for the employees to read. The data is retrieved from an Oracle database server.<\/p>\n<p>There are two situations, one with a native Oracle installation and one with a sequenced Oracle installation.<\/p>\n<p>In one situation the week starts on Sunday (zondag) in the other on Monday (maandag), resulting in a vague schedule for the employee. Although the date is correct, the corresponding day of week isn\u2019t.<\/p>\n<p><!--more--><\/p>\n<h4>Determing day of week (DOW)<\/h4>\n<p>The day of week (DOW) is determined using the TO_CHAR function and the \u2018D\u2019 parameter. This results in a numerical result, which represents the day of week. In the BO report a translation from the numerical value to a dutch day of week has been made. <\/p>\n<pre lang=\"SQL\">CASE TO_CHAR(MA.STRT,'D')\n  WHEN '1' THEN 'Zondag'\n    WHEN '2' THEN 'Maandag'\n    WHEN '3' THEN 'Dinsdag'\n    WHEN '4' THEN 'Woensdag'\n    WHEN '5' THEN 'Donderdag'\n    WHEN '6' THEN 'Vrijdag'\n    WHEN '7' THEN 'Zaterdag'\n    ELSE ''\n  END  &quot;Dag<\/pre>\n<p>In order to \u2018solve\u2019 the problem with the wrong day of week, the report operator changed the query. Although this results in the correct day of week, it isn\u2019t consistent on all environments. <\/p>\n<pre lang=\"SQL\">  CASE TO_CHAR(MA.STRT,'D')\n  WHEN '7' THEN 'Zondag'\n    WHEN '1' THEN 'Maandag'\n    WHEN '2' THEN 'Dinsdag'\n    WHEN '3' THEN 'Woensdag'\n    WHEN '4' THEN 'Donderdag'\n    WHEN '5' THEN 'Vrijdag'\n    WHEN '6' THEN 'Zaterdag'\n    ELSE ''\n  END  &quot;Dag&quot;<\/pre>\n<p>&#160;<\/p>\n<h4>Regional settings<\/h4>\n<p>The number returned by to_char(some_date,\u2019D\u2019) varies with NLS_TERRITORY. The behaviour of to_char and to_nchar can be influenced by setting the NLS_DATE_LANGUAGE, NLS_CALENDAR, NLS_NUMERIC_CHARACTERS, NLS_CURRENCY, NLS_DUAL_CURRENCY and NLS_ISO_CURRENCY NLS parameters. <\/p>\n<p>The NLS_LANG is set per machine in the registry on the location HKEY_LOCAL_MACHINE\\SOFTWARE\\ORACLE\\KEY_OraClient10g_home1\\NLS_LANG.<\/p>\n<p>&#160;<\/p>\n<h4>Configuration differences<\/h4>\n<p><a href=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2011\/06\/image.png\"><img loading=\"lazy\" decoding=\"async\" style=\"margin: 0px 5px 0px 0px; display: inline; float: right\" title=\"\" alt=\"\" align=\"right\" src=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2011\/06\/image_thumb.png\" width=\"368\" height=\"113\" \/><\/a>The Oracle installation in the sequence (containing all other applications) is configured with the \u2018AMERICAN_AMERICA\u201d language.<\/p>\n<p>&#160;<\/p>\n<p>&#160;<\/p>\n<p><a href=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2011\/06\/image1.png\"><img loading=\"lazy\" decoding=\"async\" style=\"margin: 0px 5px 0px 0px; display: inline; float: left\" title=\"\" alt=\"\" align=\"left\" src=\"https:\/\/ingmarverheij.com\/wp-content\/uploads\/2011\/06\/image_thumb1.png\" width=\"344\" height=\"110\" \/><\/a><\/p>\n<p>The NLS_LANG on the native installed Oracle client is \u2018DUTCH_THE NETHERLANDS\u2019.<\/p>\n<p>&#160;<\/p>\n<p>&#160;<\/p>\n<p>According to the <a href=\"https:\/\/download.oracle.com\/docs\/html\/B13804_02\/gblsupp.htm\">Oracle \u00ae Database Client Installation Guide<\/a>, the locale setting of your operating system determines the value of the NLS_LANG parameter at installation.<\/p>\n<p>&#160;<\/p>\n<h4>Solution<\/h4>\n<p>So, the \u201cproblem\u201d is caused by an inconsistent NLS_LANG and a Business Object report that assumes a certain syntax. The problem can be solved by setting the NLS_LANG in the sequenced version and the native installation to the same language code. <\/p>\n<p>An alternative could be to hardcode the NLS in the SQL function. The third parameter in the TO_CHAR function is the <em>nls_date_language<\/em>. This way the results is consistent, no matter what NLS_LANG is set on the client. The parameters are described in the <a href=\"https:\/\/download.oracle.com\/docs\/cd\/B19306_01\/server.102\/b14225\/ch3globenv.htm#NLSPG003\">Oracle \u00ae Database Globalization Support Guide<\/a><\/p>\n<p>&#160;<\/p>\n<p>Ingmar Verheij<\/p>","protected":false},"excerpt":{"rendered":"<p>Business Objects (BO) is used to generate a report showing the schedule of employees. In the schedule the day of week is displayed as a header, which makes it easy for the employees to read. The data is retrieved from an Oracle database server. There are two situations, one with a native Oracle installation and [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"site-container-style":"default","site-container-layout":"default","site-sidebar-layout":"default","disable-article-header":"default","disable-site-header":"default","disable-site-footer":"default","disable-content-area-spacing":"default","footnotes":""},"categories":[294],"tags":[335,337,336],"class_list":["post-2804","post","type-post","status-publish","format-standard","hentry","category-microsoft-app-v","tag-businessobjects","tag-dow","tag-oracle"],"_links":{"self":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts\/2804","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/comments?post=2804"}],"version-history":[{"count":0,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/posts\/2804\/revisions"}],"wp:attachment":[{"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/media?parent=2804"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/categories?post=2804"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ingmarverheij.com\/en\/wp-json\/wp\/v2\/tags?post=2804"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}