Translated Oracle ApEx app returning incorrect month abbreviation - oracle

We have an ApEx data entry site that is translated into both Mexican Spanish and Canadian French. One of the critical columns on most data tables is the date associated with the data. As such, there are date picker fields for each time this value is needed.
The translations automatically display the month code based on the current language (a date picked in January on the Spanish site will display 'Ene' for enero). Before the date is recorded to the DB, the application format mask 'DD-MON-RR' is applied; this understands the current language and records the value on the DB in English.
The issue is that the month of December (diciembre) is showing the abbreviation of 'Dec' rather than 'Dic'. As a result, error ORA-01843 (not a valid month) is generated and the data is not saved. However, if the entry is manually changed to ##-Dic-##, the value is recorded correctly without error.
This makes it appear that the automatically-generated month abbreviation for this language is incorrect. Is this a known error with a solution?

I don't know anything about globalization, my Apex applications are in Croatian only. However, as a workaround, perhaps you could switch to another date format mask, such as DD.MM.YYYY; doing so, you wouldn't depend on language differences.

Related

Changing format of date without using to_char - Oracle

I have to get the max payment date on an invoice and I am having trouble with the date format. I do not need the max in this formula as I am using the format in a reporting tool that is pulling the max from what it finds for me.
Using "to_char({datefield},'mm/dd/yyyy')" works for displaying that date the way we would like BUT when you use summary function MAX it does not pull the correct date because it is looking at a string and not a date (it will think 12/3/21 is larger than 3/2/22).
Another thing I have tried is trunc - "trunc({datefield})" which gives us the correct max date but it changes the formatting. For example if the date prior to the formula being applied is "8/12/21 12:00:00:000" the trunc formula will display it as 12-08-21 which is horribly wrong.
Long story short is I need a way to change a date/time to date with the format of 'mmmm/dd/yyyy' WITHOUT converting it to a string with something like to_char. Thank you!!!!
A DATE is a binary data type consisting of 7 bytes representing: century, year-of-century, month, day, hour, minute and second. It ALWAYS has all of those components and it is NEVER stored with any (human-readable) format.
What you are seeing when a date is displayed is the client application you are using to access the database making a decision to be helpful to you, the user, and display the binary DATE provided by the database in a human-readable format.
If you want to change how the DATE is displayed then you either need to:
Change the settings on the client application that controls how it formats dates when it displays them to you; or
Change the data-type so that it is no longer a DATE (which does not have a format) to a data type where the values of the date can be formatted (such as a string). You can do this using TO_CHAR.
If you want to find the maximum then do it BEFORE applying the formatting:
SELECT TO_CHAR(MAX({datefield}),'mm/dd/yyyy')
FROM your_table;

400 - Bad Request while saving Date Only field in CRM using Web API

I am using Microsoft Dynamics 365 Web API approach to interacting with CRM data.
Here I want to update the field with type: DATE and TIME.
Date value I am passing in the request body is as below:
"packfirstday":"1-15-2018"
Except for above, I have also tried with DateTime and with different date formats.
e.g.
mm-dd-yyyy
m-dd-yyyy
mm/dd/yyyy
yyyy/mm/dd
yyyy-mm-dd
PS: I try to post without date field it is saving details successfully.
The problem is not with the code, the simple misunderstanding.
There are 2 components namely Behavior & Format. You have Format set as 'Date only' not the Behavior. Behavior decides the Database terms whereas Format is used for displaying datepicker controls in Form.
So when you set the field in web api with only date part - the CRM database expects time part also.
Either set behavior also as date only, so this will work:
"packfirstday":"2018-01-15" //YYYY-mm-dd format
Or change your code to pass time part also:
"packfirstday":"2018-01-15T11:10:00.000Z" //UTC offset
Since user local behavior still expects the time part.

Oracle SQL Output to Excel - Date format issue

I ran an SQL Query for Oracle which consists of Invoice date and Check date. When these data are copied on to an Excel Spreadsheet as text, it's dispayed as ex: "13-10-31" (Oct 31, 2013). However, when converted to date format, it's displayed as "10/13/1931". I've tried different date types but it always recognizes as the first part of the text as the day, then month, then year. I need these values to be setup as a date format as I need to calculate Days Payable Outstanding and other related ratios.
Is there any way to convert these values so that Excel recognizes the day, month, and year correctly? Would there be a macro that could automate this process for existing data and data that will be added in the future?
Thank you in advance.
Firstly, I hope the data type of your date column is DATE.
Secondly, the date should always have year as YYYY and not just YY. The world has already learned from Y2K bug.
If above two points are met, then while displaying use to_char(date_column, 'mm/dd/yyyy'). Thus, with YYYY format, there won't be any confusion between year and other fields.

Oracle to SQL Server: Date Conversion & Format

I'm in the process of migrating our Data Warehouse from Oracle to SQL Server 2012.
One piece of code I use a hundred times a day in Oracle is changing the date format for a query by using something like:
To_Char(entry_date,'WMMYY') = 30612
The above allows me to grab the date (default format = DD-MON-YY eg 01-JAN-12) and change the format for the week specified (the third week of June in the above example) by simply listing the week desired.
In my mind the above is very simple and easy to use. I can change it to whatever format I want (MMYY, MMYYYY) etc. without any issues. So far I cannot figure out an easy way to do this in SQL Server 2012 and it's really starting to bother me. It's datetime2 in SQL Server.
I'm finding stuff for CAST(), CONVERT(), DATEPART() but from what I've seen there is all kinds of wacky coding and number codes (like 101, 102, I don't understand why this is) required which just seems extraneous and over complicated to me.
Have I just not found what I'm looking for yet or is this just the way it is with SQL Server? I just want to be able to do something simple like grab all the data that was entered in during the month of june or the second week of october without having to add 200 extra characters of code.
It's a switch. You are using SQL Server 2012, so look into FORMAT() function. http://technet.microsoft.com/en-us/library/hh213505%28SQL.110%29.aspx I'm not, so unfortunately I can't test anything out for you - but there are some date formatting improvements.
For those of us who aren't - , there are things you can do that will be great - once you get used to them. This isn't specific to SQL Server - but Week of Month varies from organization to organization - so you'd have to define that to get a good example for 3rd week of month, etc. Also, when using DATEPART with week or day arguments, what gets returned is determined by the setting for the first day of the week (1 -7 - ##DATEFIRST). The numeric styles for CONVERT (again check out FORMAT() if you're on 2012) are definitely not as intuitive - but you'll probably be using the same styles over and over, and you'll have them memorized quickly. If you are set on 'WMMYY' or just use something over and over that doesn't have a satisfactory built in solution- create a UDF.
data that was entered in during the month of june
DATEPART(mm,#date) = 6
current month
month(getDate())
Or this week
DATEPART(ww,GetDate())

Significance of date 02/31/2157?

I work in a large scale IT support environment. Twice now we have seen an invalid date of 02/31/2157 being inserted in an Oracle DATE column. So far I have not been able to reproduce this problem, but it appears to be happening occasionally when a user attempts to save '00/00/0000' into the column. I believe the value is originating from a PowerBuilder DataWindow update.
The application uses myriad libraries for all sorts of technologies, so this question may be a bit vague, but...
Has anyone seen the date 02/31/2157 in some established library that Oracle could be defaulting to when some other invalid date is entered? Perhaps an end-of-time concept analogous to the beginning-of-time date of 1/1/1970?
From http://download.oracle.com/docs/cd/B19306_01/server.102/b14220/datatype.htm#i1847"
Oracle uses its own internal format to
store dates. Date data is stored in
fixed-length fields of seven bytes
each, corresponding to century, year,
month, day, hour, minute, and second.
2157-256 = 1901, which seems suspiciously close to a possible epoch of 1/1/1900 (or 12/13/1901 - which is the rollover date for the Year 2038 Problem)
I'd guess that it is storing either 0x00 or 0xFF in the date bytes, then getting confused when it decodes it. (How does it deal with month 255?)
Turns out this was a powerbuilder issue. The field was created in the datawindow as required, but was programmatically changed to be non-required before saving. So a null value was being saved to a non-null database column, and powerbuilder inserted some dummy date instead of just throwing an error.
I remember getting a weird value when saving an invalid date. IIRC it was in PB 9 and we had to get an EBF for it. It was a problem with Date Editmasks and entering an invalid date that wasn't rejected. Sorry I don't have more details.

Resources