VARCHAR2 to DATE format
I would like to know what is the best way to convert the following string '2001-10-26T21:32:52+02:00' into a DATE format.
Thank you.
You could use to_timestamp_tz:
http://www.oracle.com/pls/db102/search?remark=quick_search&word=to_timestamp_tz&tab_id=&format=ranked
SQL> -- generating sample data:
SQL> with t as (
2 select '2001-10-26T21:32:52+02:00' str from dual
3 )
4 --
5 -- actual query:
6 --
7 select to_timestamp_tz(replace(str, 'T', chr(32)), 'yyyy-mm-dd hh24:mi:ss tzr') dt
8 from t;
DT
26-OCT-01 09.32.52.000000000 PM +02:00
1 row selected.
Similar Messages
-
How to Convert Varchar2 to Date format(Timestamp)
I have a date saved in varchar2 column.
how can I convert the values into date(including Time stamp), so I can use the date to compare data.
Ex: I have the value '20-03-2007 05:31:29', but this value is saved as varchar2.
how can I take from this value the date '20-03-2007 05:31:29' as date format because later i need that date completely to add days, hours and minutes?SQL> create table dd (a varchar2(15));
Table created.
SQL>
SQL>
SQL> insert into dd values (sysdate);
1 row created.
SQL> insert into dd values (sysdate);
1 row created.
SQL> insert into dd values (sysdate);
1 row created.
SQL> insert into dd values (sysdate);
1 row created.
SQL> insert into dd values (sysdate);
1 row created.
SQL> insert into dd values (sysdate);
1 row created.
SQL>
SQL> commit;
Commit complete.
SQL>
SQL> select * from dd;
A
01-OCT-12
01-OCT-12
01-OCT-12
01-OCT-12
01-OCT-12
01-OCT-12
6 rows selected.
SQL>
SQL>
SQL> select to_date(a,'dd-mon-yyyy') from dd;
TO_DATE(A
01-OCT-12
01-OCT-12
01-OCT-12
01-OCT-12
01-OCT-12
01-OCT-12
6 rows selected.
SQL> select to_timestamp(to_date(a,'dd-mon-yyyy'),'dd mon yy hh24.mi.ss' ) from dd;
TO_TIMESTAMP(TO_DATE(A,'DD-MON-YYYY'),'DDMONYYHH24.MI.SS')
01-OCT-12 12.00.00 AM
01-OCT-12 12.00.00 AM
01-OCT-12 12.00.00 AM
01-OCT-12 12.00.00 AM
01-OCT-12 12.00.00 AM
01-OCT-12 12.00.00 AM
6 rows selected.
SQL>
that's it...... -
Converting varchar2 to date format
I've converted date formats many times, but for some reason I'm getting an invalid number error when trying to convert a varchar2 column. I've tried the to_char and to_date function and I get the same result. The column is a date and it is formatted as DD-MON-YYYY, but I want to change it to MM/DD/YYYY. My query is below:
select to_date('fccpdate','MM/DD/YYYY')
from cc_class_scmast_v
When I try to_date I get this:
Error starting at line 1 in command:
select TO_DATE('fccpdate', 'DD-MON-YYYY') from cc_class_scmast_v where fccpdate IS NOT NULL
Error report:
SQL Error: ORA-01858: a non-numeric character was found where a numeric was expected
01858. 00000 - "a non-numeric character was found where a numeric was expected"
*Cause: The input data to be converted using a date format model was
incorrect. The input data did not contain a number where a number was
required by the format model.
*Action: Fix the input data or the date format model to make sure the
elements match in number and type. Then retry the operation.
When I try to_char I get this:
Error starting at line 1 in command:
select TO_char('fccpdate', 'DD-MON-YYYY') from cc_class_scmast_v where fccpdate IS NOT NULL
Error report:
SQL Error: ORA-01722: invalid number
01722. 00000 - "invalid number"
*Cause:
*Action:
I've tried removing the single quotes from my column and that doesn't make a difference. Any help is appreciated.Hi,
housetiger77 wrote:
I've converted date formats many times, but for some reason I'm getting an invalid number error when trying to convert a varchar2 column. I've tried the to_char and to_date function and I get the same result. The column is a date and it is formatted as DD-MON-YYYY,If the column is a DATE, then it has the same format that all DATEs have, which is nothing like 'DD-MON-YYYY'. Formats like that only apply to strings.
Conversely, if it is formatted as 'DD-MON-YYY', then it is a string, not a DATE.
but I want to change it to MM/DD/YYYY. My query is below:
select to_date('fccpdate','MM/DD/YYYY')
from cc_class_scmast_vTO_DATE (x, 'MM/DD/YYYY') tries to convert the string x into a DATE. Let's say it starts by taking the first 2 characters of x, to get the month. The first 2 charcters of 'fccpdate' are 'fc', which is not a valid number (at least not in base 10), let alone a number between 1 and 12, so TO_DATE raises an error.
When I try to_date I get this:
Error starting at line 1 in command:
select TO_DATE('fccpdate', 'DD-MON-YYYY') from cc_class_scmast_v where fccpdate IS NOT NULL
Error report:
SQL Error: ORA-01858: a non-numeric character was found where a numeric was expected
01858. 00000 - "a non-numeric character was found where a numeric was expected"
*Cause: The input data to be converted using a date format model was
incorrect. The input data did not contain a number where a number was
required by the format model.
*Action: Fix the input data or the date format model to make sure the
elements match in number and type. Then retry the operation.
When I try to_char I get this:
Error starting at line 1 in command:
select TO_char('fccpdate', 'DD-MON-YYYY') from cc_class_scmast_v where fccpdate IS NOT NULL
Error report:
SQL Error: ORA-01722: invalid number
01722. 00000 - "invalid number"
*Cause:
*Action:
I've tried removing the single quotes from my column and that doesn't make a difference. Any help is appreciated.That's a good first step. Literals are enclosed in single-quotes, identifiers (including column names) are not. 'fccpdate' is the literal 8-character string containing 'f', 'c;, another 'c', 'p', 'd', 'a', 't' and 'e'. fccpdate (without single-quotes) can be the name of a column.
If fccpdate is a string, such as '18-JUL-2012', then you can convert it to a DATE using TO_DATE.
TO_DATE (fccpdate, 'DD-MON-YYYY')If you want to display a DATE in a particular format, use
TO_CHAR ( d
, f
)where d is a DATE, and f is the format string. In this case, d might be the TO_DATE expression above
TO_CHAR ( TO_DATE (fccpdate, 'DD-MON-YYYY')
, 'MM/DD/YYYY'
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say which version of Oracle you're using.
See the forum FAQ {message:id=9360002} -
ORA-01821: date format not recognized Error in PL/SQL report-4.0
Hi,
I am using Apex 4.0 and i have a Classic report(function returning query) which selects a date column.
The query runs at the backend and gives the output.
But when i run the report on the page, i get the error
report error:
ORA-20001: Error fetching column value: ORA-01821: date format not recognizedThe values for the date column are like this 14-MAR-13,01-FEB-13 etc... Everything seems to be right.
But I have no idea why this error occurs.
Thanks
DivyaAren't these errors annoying! But there's a data / format mismatch for sure. What I need to see -- and what will tell you what is wrong -- is
1) exactly what the data is and
2) exactly what the format string is that is being used to convert it.
The values for the date column are like this 14-MAR-13,01-FEB-13 etc... Question: Is this the source data or the target data ( what it's supposed to look like after being converted)?
Let's start there:
What is the source? Is it a DB column? Is it type date or VARCHAR2 or what?
If VARCHAR2, then give us an example of the data that is failing.
What is the format -- I assume there is one -- being used to convert the data?
Are you doing a TO_CHAR or a TO_DATE?
Give us lots of detail, please. Then it should be easy to solve.
Regards,
Howard -
How to handle Multiple date formats for the same date field in SQL*Loader
Dear All,
I got a requirement where I need to get data from a text file and insert the same into oracle table.
I am using SQL*Loader to populate the data from the text file into my table.
The file has one field where I am expecting date date data in multiple formats, like dd/mon/yyyy, yyyy/dd/mon, yyyy/mon/dd, ,mm/dd/yyyy, mon/dd/yyyy.
While using SQL*Loader, I can see Loading is failing for records where we have formats like yyyy/dd/mon, yyyy/mon/dd, mon/dd/yyyy.
Is there any way in SQL*Loader where we can mention all these date formats so that this date data should go smoothly into the underlying date column in the table.
Appreciate your response on this.
Thanks,
Madhu K.The point being made was, are you sure that you can uniquely identify a date format from the value you receieve? Are you sure that the data stored is only of a particular limited set of formats?
e.g. if you had a value of '07/08/03' how do you know what format that is?
It could be...
7th August 2003 (thus assuming it's DD/MM/RR format)
or
8th July 2003 (thus assuming it's MM/DD/RR format)
or
3rd August 2007 (thus assuming it's RR/MM/DD format)
or
8th March 2007 (thus assuming it's RR/DD/MM format)
or even more obscurely...
3rd July 2008 (MM/RR/DD)
or
7th March 2008 (DD/RR/MM)
Do you have any information to tell you what formats are valid that would allow you to be specific and know what date format is meant?
This is a classic example of why dates should be stored on the database using DATE datatype and not VARCHAR2. It can lead to corruption of data, especially if the date can be entered in any format a user wishes. -
How can i convert a the date format 'm/d/yyyy hh:mi:ss AM' to 'MM/DD/YYYY HH:MI:SS AM' in Oracle
I have a query
select UPPER(t.val_10) "TYPE", count(val_3) "Number of Transfers"
from table1 t
where t.is_active = 1
and t.val_4 = 'INBOUND'
and to_date(to_date(val_5,'MM/DD/YYYY HH:MI:SS AM'), 'DD/MM/YY') between to_date(to_date('01/08/2008 00:00:00','DD/MM/YYYY HH24:MI:SS'), 'DD/MM/YY') and add_months(to_date(to_date('01/08/2008 00:00:00','DD/MM/YYYY HH24:MI:SS'), 'DD/MM/YY'),1)
group by UPPER(t.val_10)
order by UPPER(t.val_10)
I get the error [ORA-01861: literal does not match format string which i think is because
val_5 has the values in the following format:
8/29/2008 6:31:10 PM
Does anyone have an answer?
Thanks in advance
Edited by: user2360027 on 26-Mar-2009 03:50first off, you've got to_date(to_date(...)) - NEVER do this - you're forcing an implicit to_char which can cause all sorts of problems!
What is the data type of your column val_5? If it's DATE then your query is simply:
select UPPER(t.val_10) "TYPE",
count(val_3) "Number of Transfers"
from table1 t
where t.is_active = 1
and t.val_4 = 'INBOUND'
and val_5 between to_date('01/08/2008','DD/MM/YYYY') and add_months(to_date('01/08/2008','DD/MM/YYYY') ,1)
group by UPPER(t.val_10)
order by UPPER(t.val_10)If it's a varchar2 (why, oh why, oh why, ...?!), then your query should be:
select UPPER(t.val_10) "TYPE",
count(val_3) "Number of Transfers"
from table1 t
where t.is_active = 1
and t.val_4 = 'INBOUND'
and to_date(val_5, 'mm/dd/yyyy hh:mi:ss AM') between to_date('01/08/2008','DD/MM/YYYY') and add_months(to_date('01/08/2008','DD/MM/YYYY') ,1)
group by UPPER(t.val_10)
order by UPPER(t.val_10)Remember that dates in DATE format are stored in an internal Oracle format - in order for you to tell Oracle that your string is a date, you need to use to_date. When you want to retrieve a date, you need to use to_char to put it into the format you want to see it in.
Remember also that your nls_date_format defines the default format that you'll see a date, which is what is used in the implicit conversion that oracle does when you select a date:
SQL> alter session set nls_date_format='dd/mm/yyyy hh24:mi:ss';
Session altered.
SQL> select sysdate from dual;
SYSDATE
26/03/2009 11:01:53
1 row selected.
SQL> alter session set nls_date_format='mm/dd/yy hh12:mi:ss AM';
Session altered.
SQL> select sysdate from dual;
SYSDATE
03/26/09 11:02:24 AM
1 row selected.It doesn't make sense to convert something that's already in a DATE format into a DATE format - in order to do that, oracle has to first change the date into a string, and it does that by using the nls_date_format parameter setting - if you're working with dates-in-strings that are in a different format, then all sorts of problems arise, as you have found out! -
Hi All,
I have creted the snapshot as
CREATE SNAPSHOT EMPLOYEE_CRIS_MVIEW
PCTFREE 10
PCTUSED 40
MAXTRANS 255
TABLESPACE users
STORAGE (
INITIAL 40960
NEXT 73728
PCTINCREASE 1
MINEXTENTS 1
MAXEXTENTS 505
BUILD IMMEDIATE
REFRESH ON DEMAND
With rowid
AS
select
emp_id,
join_dt,
emp_stat,
from employee_CRIS
The date format for the column join_dt is dd-mon-yyyy.
But I want to modify the date format for this column as 'MM/DD/YYYY'.
For that I tried
ALTER snapshot EMPLOYEE_CRIS_MVIEW modify(TO_CHAR(join_dt,'MM/DD/YYYY'));
But I got the error
ERROR at line 1:
ORA-00902: invalid datatype
Could you please help me to change the change the date format of the column of the snapshot
with out dropping the snapshot.
Please help me.
Thanks in advance.What people are saying is that date columns (of DATE datatype) are stored internally using a fixed internal notation, which is essentially a series of bytes that describe the date.
e.g.
SQL> select empno, ename, hiredate, dump(hiredate) as dump_hiredate from emp;
EMPNO ENAME HIREDATE DUMP_HIREDATE
7369 SMITH 17/12/1980 00:00:00 Typ=12 Len=7: 119,180,12,17,1,1,1
7499 ALLEN 20/02/1981 00:00:00 Typ=12 Len=7: 119,181,2,20,1,1,1
7521 WARD 22/02/1981 00:00:00 Typ=12 Len=7: 119,181,2,22,1,1,1
7566 JONES 02/04/1981 00:00:00 Typ=12 Len=7: 119,181,4,2,1,1,1
7654 MARTIN 28/09/1981 00:00:00 Typ=12 Len=7: 119,181,9,28,1,1,1
7698 BLAKE 01/05/1981 00:00:00 Typ=12 Len=7: 119,181,5,1,1,1,1
7782 CLARK 09/06/1981 00:00:00 Typ=12 Len=7: 119,181,6,9,1,1,1
7788 SCOTT 19/04/1987 00:00:00 Typ=12 Len=7: 119,187,4,19,1,1,1
7839 KING 17/11/1981 00:00:00 Typ=12 Len=7: 119,181,11,17,1,1,1
7844 TURNER 08/09/1981 00:00:00 Typ=12 Len=7: 119,181,9,8,1,1,1
7876 ADAMS 23/05/1987 00:00:00 Typ=12 Len=7: 119,187,5,23,1,1,1
7900 JAMES 03/12/1981 00:00:00 Typ=12 Len=7: 119,181,12,3,1,1,1
7902 FORD 03/12/1981 00:00:00 Typ=12 Len=7: 119,181,12,3,1,1,1
7934 MILLER 23/01/1982 00:00:00 Typ=12 Len=7: 119,182,1,23,1,1,1
14 rows selected.Here, you can see from the dumped dates that they are all stored as 7 bytes of data, which sort of resemble the date you see on the screen in some way, but not quite. It's an internal format that Oracle understands and uses, and it's important it's stored in this way so that date arithmetic and date range comparisons can be performed easily (and quickly) in queries.
If we were to alter our sessions date format (the display format for our session only) and query the data again in the same way...
SQL> alter session set nls_date_format='YYYY-MM-DD';
Session altered.
SQL> select empno, ename, hiredate, dump(hiredate) as dump_hiredate from emp;
EMPNO ENAME HIREDATE DUMP_HIREDATE
7369 SMITH 1980-12-17 Typ=12 Len=7: 119,180,12,17,1,1,1
7499 ALLEN 1981-02-20 Typ=12 Len=7: 119,181,2,20,1,1,1
7521 WARD 1981-02-22 Typ=12 Len=7: 119,181,2,22,1,1,1
7566 JONES 1981-04-02 Typ=12 Len=7: 119,181,4,2,1,1,1
7654 MARTIN 1981-09-28 Typ=12 Len=7: 119,181,9,28,1,1,1
7698 BLAKE 1981-05-01 Typ=12 Len=7: 119,181,5,1,1,1,1
7782 CLARK 1981-06-09 Typ=12 Len=7: 119,181,6,9,1,1,1
7788 SCOTT 1987-04-19 Typ=12 Len=7: 119,187,4,19,1,1,1
7839 KING 1981-11-17 Typ=12 Len=7: 119,181,11,17,1,1,1
7844 TURNER 1981-09-08 Typ=12 Len=7: 119,181,9,8,1,1,1
7876 ADAMS 1987-05-23 Typ=12 Len=7: 119,187,5,23,1,1,1
7900 JAMES 1981-12-03 Typ=12 Len=7: 119,181,12,3,1,1,1
7902 FORD 1981-12-03 Typ=12 Len=7: 119,181,12,3,1,1,1
7934 MILLER 1982-01-23 Typ=12 Len=7: 119,182,1,23,1,1,1
14 rows selected.... whilst the hiredate is now showing on the screen in the format we've chosen, the actual internal storage of those dates remains completely unchanged. i.e. we don't have to change the format of the internal storage of dates to make them display differently.
Likewise you can format dates manually as part of your query using to_char function...
SQL> select empno, ename, to_char(hiredate,'DD Month YYYY') as hiredate, dump(hiredate) as dump_hiredate from emp;
EMPNO ENAME HIREDATE DUMP_HIREDATE
7369 SMITH 17 December 1980 Typ=12 Len=7: 119,180,12,17,1,1,1
7499 ALLEN 20 February 1981 Typ=12 Len=7: 119,181,2,20,1,1,1
7521 WARD 22 February 1981 Typ=12 Len=7: 119,181,2,22,1,1,1
7566 JONES 02 April 1981 Typ=12 Len=7: 119,181,4,2,1,1,1
7654 MARTIN 28 September 1981 Typ=12 Len=7: 119,181,9,28,1,1,1
7698 BLAKE 01 May 1981 Typ=12 Len=7: 119,181,5,1,1,1,1
7782 CLARK 09 June 1981 Typ=12 Len=7: 119,181,6,9,1,1,1
7788 SCOTT 19 April 1987 Typ=12 Len=7: 119,187,4,19,1,1,1
7839 KING 17 November 1981 Typ=12 Len=7: 119,181,11,17,1,1,1
7844 TURNER 08 September 1981 Typ=12 Len=7: 119,181,9,8,1,1,1
7876 ADAMS 23 May 1987 Typ=12 Len=7: 119,187,5,23,1,1,1
7900 JAMES 03 December 1981 Typ=12 Len=7: 119,181,12,3,1,1,1
7902 FORD 03 December 1981 Typ=12 Len=7: 119,181,12,3,1,1,1
7934 MILLER 23 January 1982 Typ=12 Len=7: 119,182,1,23,1,1,1
14 rows selected.
SQL>Again, the internal date format remains the same.
It is important that, when you store date information you store it as DATE datatype and let oracle use it's internal format, so that it can accurately do the date arithmetic, date range searches and date ordering etc., that everyone likes to do in queries. If you try and store it as VARCHAR2 then not only can information be lost (i.e. is '01/02/2010' representing 1st February 2010 or is it 2nd January 2010?) but you prevent date arithmetic, range searches and ordering in your queries from working correctly (i.e. '03/01/2009' would work out to be a greater date than '01/02/2010'). To prove it...
SQL> select 'Wrong' from dual where '03/01/2009' > '01/02/2010';
'WRON
Wrong
SQL> ed
Wrote file afiedt.buf
1* select 'Wrong' from dual where to_date('03/01/2009','DD/MM/YYYY') > to_date('01/02/2010','DD/MM/YYYY')
SQL> /
no rows selected -
Hi,
I have a table with a date field that comes as varchar2(20byte) with a content like this:
20/Jan/2011
and I need it to be converted toa real date format e.g. 20.01.2011.
Please help,
Thanks
WalterHi, Walter,
user457173 wrote:
Hi,
I have a table with a date field that comes as varchar2(20byte) with a content like this:
20/Jan/2011
and I need it to be converted toa real date format e.g. 20.01.2011.'20/Jan/2011' is actually just as "real" as '20.01.2011'. Neither is a real DATE; both are strings.
Please help,
Thanks
WalterUse TO_DATE to convert a string into a DATE:
TO_DATE ( column_x
, 'DD/Mon/YYYY'
)Use TO_CHAR to display a DATE in a given format:
TO_CHAR ( d
, 'DD.MM.YYYY'
)d can be any DATE, including the DATE returned by the TO_DATE function, above.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say what version of Oracle you're using.
Edited by: Frank Kulash on Oct 25, 2011 7:57 AM -
Date Format on OWB 11.1.0.7 to use for input parameter for a mapping
All,
What is the Date Format on OWB 11.1.0.7 to use for passing in an input parameter for a mapping to execute?
I have tried '01-01-2010','01-JAN-2010','01.01.2010', 01/01/2010 and I get the following error:
Error RPE-01003: An infrastructure condition prevented the request from completing.
Error RPE-01038: Failed to evaluate expression declare l_expression DATE := 01/01/2010;begin :result := wb_rt_conversions.from_date(l_expression);end;. Please modify the expression, redeploy and retry again.
RA-06550: line 1, column 32:
PLS-00382: expression is of wrong type
ORA-06550: line 1, column 24:
PL/SQL: Item ignored
ORA-06550: line 1, column 90:
PLS-00320: the declaration of the type of this expression is incomplete or malformed
ORA-06550: line 1, column 51:
PL/SQL: Statement ignored
I am using a Mapping Input parameter object and have a START_DATE_IN as a DATE and an END_DATE_IN as a DATE
Any information you could provide would be greatly appreciated.
Thanks,
ShaunHello Shaun,
The function wb_rt_conversions.from_date is (at least in OWB10.2) overloaded and can with input-types as
date, timestamp_unconstrained, timestamp_tz_unconstrained, timestamp_ltz_unconstrained or varchar2.
If it doesn't work with varchar2 I would try Date:
For example: to_date('2010-01-01','YYYY-MM-DD')
I also found this thread:
http://kr.forums.oracle.com/forums/thread.jspa?threadID=608257
Hoping this helps...
Guenther -
Convert Oracle date format masks to Java format masks
Have an application based on Oracle that stores data in text form (for display) and in native date format. It is being migrated to another application with a Java based front end that can only use Java format masks to display the dates in the desired display format.
Is there a way to translate the Oracle format masks to Java? I can do this in SQL or PL/SQL using the database or in Java.
I really don't want to write detailed code to parse the masks, although if parsers are available to take an oracle mask into its metadata (minute, year, etc), it may be possible for me to write the code.
This seems like something that must have been done many times over the years. I would prefer to reuse workable code rather than reinventing the wheel.
To be clear, I do not need to alter data or convert dates shown in string form. Just the format masks so the new app will display dates in the same manner as the old app. Fortunately, both apps handle interpreting the format masks in their native technology, so it is just converting the format mask.kenmadsen wrote:
Both applications have a varchar2 column and a date column. A date picker selects and returns the date in native format for storage and the application uses the mask to format the varchar2 column for display (and storage). The old application uses an Oracle date format mask DD-Mon-YYYY HH24:MI and the new application uses Java date masks (DD-MM-YYYY hh:mm). (I may not have the translation from HH24 to hh correct).
The date column and the display column store the same information (a date), but one is stored natively and the other is displayed as the application administrator want the particular row to be formatted for display. (the mask is a column in the same table as the other 2 columns). Each row has characteristics (other columns) that determines what the data is and how it should be shown (some things need to show time; others only the date)
So the problem is, when migrating, the new application cannot render the dates as the old app did because "Mon" is Oracle format, not Java format.
No data is being converted in the migration, except for the mask itself. Both applications have the same record structure with respect to these columns and they both use the mask to generate the formatted varchar2 data for display in the application and storage.too bad you insist on try to describe with words rather than actual CODE.
Please explain again why this is an Oracle problem & NOT a Java problem?
Oracle RDBMS is a data repository & can't automagically change data content for you. -
Date format Problem in forms&reports Services 10g
Hi Dears,
I Faced a problem during running reports ( i am using forms& Reports Services 10g), when i pass the parameters via parameter form to the report (built in forms10g Rel 2.0) its appearing in arabic like (25-يناير-2010) as my Date Formate is (DD-YYYY-MON) and NLS_LANG parameter is defined as Arabic_Saudi arabia.AR8MSWIN1256 so as a result report is not running due to unknown Date formate, how can i change the Same Date format (DD-YYYY-MON) to appear in english like (25-2010-JAN)
ThanksYou could specify the parameter as type VARCHAR2, explicitly cast it (maybe to DD.MM.YYYY) when you pass it from forms and cast it back in your query, like TO_DATE(:P_PARAM, 'DD.MM.YYYY')
-
How can I change the date format in iStudio ? Actually, the date format looks like "juin 10, 2004".
I think you are correct. You cannot change the internal OAI date format. The date format is controlled by the java code within the OAI solution. (I'm not sure where, but probably within oai.jar - Perhaps some Java guru on this Forum can point to the class(es) concerned which control the internal OAI date format just for general information?).
Can you simply pass the date through as a String attribute instead of a date attribute, then format or reformat it in either the source or target system?
Another thing you could try (this is the way in which I've retreived the 'sysdate' in the past in order to pass it to a target field) was to create a PL/SQL function on the database. I used the Database Operation transformation to call the function. The function simply returns a value to your target field.
My function returned the actual value as a VARCHAR2 - however, my target field had a DATE data type - so, OAI reformatted the value to the OAI date format.
There is no reason, however, why you can't do something similar and pass the value to an attribute with a String data type (not a DATE data type). This would stop the InterConnect reformatting it. -
Update date format in SQL developer
I need to convert date format in SQL developer , it's varchar2 format now
The current format is yyyy/mm/dd-hh:mm:ss:sss and I need to convert it to yyyy-mm-dd hh:mm:ss CST
I don't really know SQL but did some research and found that I can use instr to find the string and replace it, however, no matter what I try,there is always something off :(
Could anyone here help me with it? thanks in advance.create table xo_custom_date_format (mydateAsChar varchar2(100));
table XO_CUSTOM_DATE_FORMAT created.
insert into xo_custom_date_format
values ('2012/03/23-09:52:24:123')
+1 rows inserted.+
select mydateasChar from xo_custom_date_format
mydateaschar
+2012/03/23-09:52:24:123+
select to_timestamp(mydateaschar, 'YYYY/MM/DD-HH24:MI:SS:FF3') mydateAsTimestamp from xo_custom_date_format
-- We must convert to timestamp data type, rather than date data type as you have fractions of seconds
mydateAsTimestamp
+23-MAR-12 09:52:24.123000000 --<-- This will probably appear differently, depending on your database NLS_ settings (i.e. what country you are in)+
select to_char( to_timestamp(mydateaschar, 'YYYY/MM/DD-HH24:MI:SS:FF3') , 'YYYY-MM-DD HH24:MM:SS')||' CST' as myDateReformatted
from xo_custom_date_format
mydateReformatted
+2012-03-23 09:03:24 CST+ -
Date format in the file datastore
Hi,
I have source as file, in which I have date column. While creating the file datastore, I have selected the datatype as date & have given the source date format in the format column and it is working fine.
But I have source file coming with different date formats for the same column.
My question is whether i can give multiple date formats in the format column??
1. If yes how to separate the formats i.e with comma or semi-colon or etc...
2. If No, thn how to achieve it. as I can use to_date function, but in that also I have to give all the date formats.Assuming Oracle is target database..
Try this...
1. In your file data store make the column as Varchar2
2. In the interface mapping -- specify the following string in the target column mapping
TO_DATE(REPLACE('2011-06-01','-',''),'YYYYMMDD')
If your target column is date, Oracle will convert database proper format and insert the date..
Hope this works out....
Thanks
Satish
Edited by: user12826256 on 01-Jul-2011 02:15 -
DECLARE
err_mesg_out NUMBER(1):=0;
x DATE;
y VARCHAR2(50) := Null;
z DATE;
BEGIN
select scheduled_date into x
from CONTRACT_SCHEDULED_FULFILLMENT where CONTRACT_ID=94875672 and fulfillment_type_id=9;
dbms_output.put_line('x ='||x);
select TO_CHAR(scheduled_date,'MM/DD/YYYY HH24:MI:SS') into y
from CONTRACT_SCHEDULED_FULFILLMENT where CONTRACT_ID=94875672 and fulfillment_type_id=9;
dbms_output.put_line('y ='||y);
z := TO_DATE(y,'MM/DD/YYYY HH24:MI:SS');
dbms_output.put_line('z ='||z);
--my_proc(10001,20002,z,err_mesg_out);
END;
OutPut
x =14-feb-2011
y =02/14/2011 11:46:24
z =14-feb-2011
err_mesg_out =0I want to get the 'z' variable value in 'MM/DD/YYYY HH24:MI:SS' format in my session. Why I think so is because the same format/value need to be passed to
a procedure "my_proc" - which is currently commented out. Even if I hardcode the 'z' param value while calling the "my_proc" it still throwing exception
my_proc(10001,20002,'02/14/2011 11:46:24',err_mesg_out);
ORA-01843: not a valid monthWhen this procedure is getting executed from the application code with the same value/format it's working fine and I think something need to be done in my SQLPLUS session. Can anyone suggest how I can set the date format to resolve this ?Hi,
As Blushadow said, format (such as the difference between '16-Feb-11' and '02/16/2011 05:08:13') is something that applies only to strings, not DATEs. All DATEs have the same (purely internal) format, which has nothing to do with how they appear when you display them.
By the way, assuming you want the variables x and y, the following code does exactly the same as what you posted:
DECLARE
err_mesg_out NUMBER (1) := 0;
x DATE;
y VARCHAR2 (50) := Null;
z DATE;
BEGIN
select scheduled_date
into x
from CONTRACT_SCHEDULED_FULFILLMENT
where CONTRACT_ID = 94875672
and fulfillment_type_id = 9;
dbms_output.put_line ('x =' || x);
y := TO_CHAR (x, 'MM/DD/YYYY HH24:MI:SS');
dbms_output.put_line ('y =' || y);
z := x;
dbms_output.put_line ('z =' || z);
-- my_proc (10001, 20002, z, err_mesg_out);
END;
/ There's no need to query the table more than once, and it's just plain silly to convert a DATE (such as scheduled_date) into a string (such as y), just so you can convert it back to a DATE (such as z) again.
If all you want to do is call my_proc, then the following is all you need:
DECLARE
err_mesg_out NUMBER (1) := 0;
z DATE;
BEGIN
select scheduled_date
into z
from CONTRACT_SCHEDULED_FULFILLMENT
where CONTRACT_ID = 94875672
and fulfillment_type_id = 9;
dbms_output.put_line ('z =' || z);
-- my_proc (10001, 20002, z, err_mesg_out);
END;
/
Maybe you are looking for
-
Reg: Excluded Section in Pivot view
Hi,, can any one telme.. how exactly the 'Excluded Section' in the pivot view, will effect the entire report. In one of my report when i place one column in excluded section, one set of data is coming, when i remove that column in the Excluded sectio
-
Problem calling more than one instance of a dll from TestStand
Hi, I've posted this message in the LabWindows forum a few days ago and haven't gotten any answer. I have made a DLL with the evaluation version of LabWindows 7.1 to connect to a Telnet server and perform various commands. This DLL is used with TestS
-
OBIEE Answers 10 g: I want to select customer number column and select ecommerce metrics like orders and revenue against it . how do i select distinct customer Number in OBI answers . at present we do not have distinct values and i only have access t
-
FTP syntax (Check plz)
Hello Sorry for the loooooong post but can someone tell me why it ain't working? //FTPApp.java import java.awt.*; import java.awt.event.*; import java.util.*; import java.io.*; import java.net.*; import java.lang.reflect.*; import sun.net.ftp.*; impo
-
Loading UI components from config file
Hi, I wanted to know your opinion about a project that i'm working on. The inicial idea of the project is to have a config file (file.ini) with a syntax similar to this one: [Component1] type = sevenseg width = 200 height = 50 numberOfDigits = 5 fore