Function in to_date format...
Hi I have one function which retun value in mm/dd/yyyy format. inside select clause iwant compare this function with mm/yyyy format. but function can not come with to_date format. need help to work wround due to this select query out put getting generated wrong.
select to_date( fnbudgetstartdt (110626),'mm/yyyy') from dual; I want this function should return value in mm/yyyyy
as I can not chnage function as it has been used in multiple place.
Plesse do suggest work around.
Help is iappreciated.
HEre is formaated code
SELECT MONTH AS nmonth, YEAR AS nyear, subcosttypeid, monthindicator,
(SELECT fngovfactorinfo (TO_DATE (MONTH || '/' || YEAR, 'mm/yyyy'),
1,
ostt.subcosttypeid,
3
FROM DUAL) AS rate,
(SELECT osd.costhourindbudget
FROM optionssubcostdetails osd
WHERE osd.subcosttypeid = ostt.subcosttypeid) budgetindicator
FROM (SELECT MONTH, YEAR, subcosttypeid, ost.swcapgrpid,
CASE
WHEN TO_DATE (t.MONTH || '/' || t.YEAR,
'mm/yyyy'
) >= TRUNC (fnbudgetstartdt (110626), 'mm')
AND TO_DATE (MONTH || '/' || YEAR, 'mm/yyyy') <=
TRUNC (fnbudgetenddt (110626), 'mm')
THEN CASE
WHEN TO_DATE (t.MONTH || '/' || t.YEAR, 'mm/yyyy') <=
(SELECT MAX (TO_DATE (MONTH || '/' || YEAR,
'mm/yyyy'
FROM cmpmclosedmonth ccm
WHERE ccm.cost_indicator = 'C')
THEN 'C'
ELSE 'O'
END
ELSE 'NA'
END AS monthindicator
FROM (WITH startend AS
(SELECT (SELECT TRUNC
(fnbudgetstartdt (110626),
'yyyy'
FROM DUAL) AS start_date,
(SELECT ADD_MONTHS
(TRUNC (fnbudgetenddt (110626),
'yyyy'
12
- 1
FROM DUAL) AS end_date
FROM DUAL)
SELECT TO_CHAR (ADD_MONTHS (TRUNC (start_date, 'mm'),
LEVEL - 1
'mm'
) MONTH,
TO_CHAR (ADD_MONTHS (TRUNC (start_date, 'mm'),
LEVEL - 1
'yyyy'
) YEAR
FROM startend
CONNECT BY TRUNC (end_date, 'mm') >=
ADD_MONTHS (TRUNC (start_date, 'mm'), LEVEL - 1)) t,
optionssubcosttype ost
WHERE ost.active = 1) ostt
Similar Messages
-
To function with the format VTR. Can anyone help?
ok i have final cut pro but i use a dvd recorder to record all of my shows and I was trying to figure out if Final cut Pro has a way to function with the format VTR. Can anyone help?
If you want to record directly to the DVD recorder, you'll most likely find that most DVD recorders with a Firewire input will NOT record directly from your Mac. I'm only aware of a couple of models (long since discontinued) that would allow it. So what you have to do it to connect your Mac via Fireiwre to a digital-to-analog converter (most any DV camcorder, VTR or DV converter box), then connect the converting device to your DVD recorder using the analog connections.
If you want to capture from the DVD recorder (hard drive or disc), you can usually do that via Firewire directly to your Mac: in FCP, set Device Control to "Non-Controllable Device" and use Capture Now. Do not expect FCP to control the DVD recorder like it can with camcorders and VTRs.
-DH -
Function to get formated WBS element
Hi,
I need a function which return formated WBS element by mask.
The input is pspnr or pspid.
The output is something like pspid but formated by mask.
Thank you.
Mariantry
CONVERSION_EXIT_ABPSN_INPUT
CONVERSION_EXIT_ABPSN_OUTPUT -
Quick Time 7 Pro's export function for iPod format failed
The export function starts to format a video for the fixed iPod format. At 17% of the reformating job, the process stops?!
Does everyone knows a solution for that? Thanks in advance.
Siemens Windows XP
Siemens Windows XPExporting to the iPod settings takes a long time.
Try a test using a one minute "cut" from your file. Time the export and you'll have an idea how long the entire file will take to export. -
A view, function and TO_DATE causing an error.
I have the following statement which calls a view, VW_DIST_RPT_WORK_LIST which in turn calls a function which returns either 'Null' or a date string e.g. '07 Oct 2003' as a VARCHAR2 (alias PROJECTED_DELIVERY_DATE).
Statement:
SELECT CUSTOMER_NAME, PROTOCOL_REFERENCE, SHIPPING_REFERENCE, CUSTOMER_REFERENCE, COUNTRY, PROJECTED_DELIVERY_DATE, STATUS, NOTES,
TO_DATE(PROJECTED_DELIVERY_DATE)
FROM VW_DIST_RPT_WORK_LIST
WHERE EXPECTED_DESP_DT IS NOT NULL
AND UPPER(PROJECTED_DELIVERY_DATE) NOT LIKE('NULL%')
AND EXPECTED_DESP_DT <= TO_DATE('07/10/2003', 'DD/MM/YYYY')
AND TO_DATE(PROJECTED_DELIVERY_DATE) <= TO_DATE('31/12/2003', 'DD/MM/YYYY') --< Problem here
I need to be able to specify a date filter on the PROJECTED_DELIVERY_DATE field and hence used the TO_DATE(PROJECTED_DELIVERY_DATE) <= TO_DATE('31/12/2003', 'DD/MM/YYYY') but this is generating an ORA-01858: a non-numeric character was found where a numeric character was expected.
I think the problem lies with the fact that this field can contain 'Null' which cannot be converted to a date using TO_DATE. I've tried adding a NOT LIKE ('NULL%') statement to catch any nulls which may be creeping in bu this doesn't solve the problem.
I've added TO_DATE(PROJECTED_DELIVERY_DATE) to the select above to determine if the nulls are being caught and if the TO_DATE in performing the conversion correctly which it is on both counts.
Any ideas anyone ?The answer provided above by Monika will work for this situation. However, you should seriously think whether you should be using a string for date datatype. Ideally, you should rewrite the function that returns PROJECTED_DELIVERY_DATE and change the return type to DATE. The least you should do is to return NULL (instead of the string 'NULL') from the function. Oracle handles nulls perfectly, there is no reason you should write code to handle nulls;
One more thing. Looking at the type of error you are receiving, it seems that you are using rule based optimizer. Why do I think so? Because, in rule based optimizer, the conditions are evaluated in a specific order (viz, bottoms-up for AND clauses). To show this, look at the following simple demonstration. I did this in Oracle 8.1.6 (also in 9.2.0.4.0 on Windows).
-- Check the database version
select * from v$version;
BANNER
Oracle8i Enterprise Edition Release 8.1.6.1.0 - Production
PL/SQL Release 8.1.6.1.0 - Production
CORE 8.1.6.0.0 Production
TNS for Solaris: Version 8.1.6.0.0 - Production
NLSRTL Version 3.4.0.0.0 - Production
-- Create the test table
create table test (a number(2));
insert into test(a) values (0);
insert into test(a) values (1);
insert into test(a) values (2);
insert into test(a) values (3);
insert into test(a) values (4);
insert into test(a) values (5);
insert into test(a) values (6);
insert into test(a) values (7);
commit;
-- See that I have not analyzed the table. This will make use of RULE based optimizer
select * from test
where a > 0
and 1/a < .25;
and 1/a < .25
ERROR at line 3:
ORA-01476: divisor is equal to zero
-- Look at the query clause. Even though I specifically asked for records where a is positive
-- the evaluation path of rule based optimizer started at the bottom and as it evaluated the
-- first row with a=0, and caused an error.
-- Now look at the query below. I just re-arranged the conditions so that a > 0 is evaluated
-- first. As a result, the row with a=0 is ignored and the query executes without any problem.
select * from test
where 1/a < .25
and a > 0;
A
5
6
7
-- Now I analyze the table to create statistics. This will make the query use the
-- cost based optimizer (since optimizer goal is set to CHOOSE)
analyze table test compute statistics;
Table analyzed.
-- Now I issue the erring query. See it executes without any problem. This indicates that
-- the cost based optimizer was intelligent enough to evaluate the proper path instead of
-- looking only at the syntax.
select * from test
where a > 0
and 1/a < .25;
A
5
6
7
Does the above example seem familiar to your case? Even though you had the AND UPPER(PROJECTED_DELIVERY_DATE) NOT LIKE('NULL%') in your query, a record with PROJECTED_DELIVERY_DATE = 'NULL' was evaluated first and that caused the error.
Summary
1. Use dates for dates and strings for strings
2. Use cost based optimizer
Thanks
Suman -
ERROR IN TO_DATE FORMAT
Hi everyone,
As you know exists an error: ORA-01855 AM/A.M. or PM/P.M
This error gets when you try to execute some query like this:
SELECT TO_DATE('01-01-2009 8:01:09 P.M.','DD-MM-YYYY HH:MI:SS PM') FROM DUAL
In this query the value of varchar is "01-01-2009 8:01:09 P.M.", finishing with P.M., that is the letter P and M follows of a dot.
If you execute this query the error 01855 will show. Also if you change the "PM" in the format part by "P.M." the error follows showing.
SELECT TO_DATE('01-01-2009 8:01:09 P.M.','DD-MM-YYYY HH:MI:SS P.M.') FROM DUAL
But if you execute this query , but only changing the "P.M." in the value part by "PM" this display the correct result.
SELECT TO_DATE('01-01-2009 8:01:09 PM','DD-MM-YYYY HH:MI:SS PM') FROM DUAL;
Having of an input value a varchar2 with '01-01-2009 8:01:09 P.M.' as value,
How can I convert in the format 'DD-MM-YYYY HH:MI:SS AM'?,
This must be without deleting the dots in the "P.M." part?
Any help will be very appreciated.
Thank you in advance.
Best RegardsYour post is very confusing but I ran the following queries and both worked successfully on a 10.2.0.3 environment:
SQL > SELECT TO_DATE('01-01-2009 8:01:09 P.M.','DD-MM-YYYY HH:MI:SS P.M.') FROM DUAL;
TO_DATE('01-01-2009
01/01/2009 20:01:09
SQL > SELECT TO_DATE(REPLACE('01-01-2009 8:01:09 P.M.','.',''),'DD-MM-YYYY HH:MI:SS PM') FROM DUAL;
TO_DATE(REPLACE('01
01/01/2009 20:01:09
SQL >The first one, is one that in your post says generates an error. The second replaces the periods with nothing. However, this is conditional on no other periods being used in your date format.
HTH! -
Function Modules for Format Date, Month Name and Quarter value.
Hi All,
1. I am getting the date field from the Flatfile, so i need to format the date to YYYYMMDD. Is there any Function module for that in BW.
2. Based on the above Formated Date i have to find out the Name of the Month like JANUARY, FEBUARY etc.
3. Based on the same above Formated Date i need to find out the Quarter like 1, 2 etc.
Could you please let me know if any function modules are there for the above questions in BW not in ABAP, why i mention is some Function modules are there in ABAP but not in BW.
Thanks in advance.
Regards,
srinivasHi ,
1.If your input date format is MMDDYYYY then Use SDATE as conversion routine in trans strucutre to convert into YYYYMMDD.
2.By passing year as input parameter for the following FM you would get all the months with text.Using READ statement in routine you can get month name
MONTH_NAMES_GET
3.For Quarters you can use the following FM:
TSTR_PERIODS_QUARTERS
hope it helps...
regards,
Raju -
Hi I am new to oracle xml.
In the below scenario how can use the functions like (to_char,To_date,trim..etc) In oracle xmltable."username","password" are inputs to my procedure.
SELECT *
INTO l_username,
l_password
FROM xmltable('/InputParameters/ParamSet'
passing l_xmldoc
COLUMNS
l_username VARCHAR2(28) path 'username',
l_password VARCHAR2(28) path 'password'
and please Help how to write above with xmlquery.
Thanks,In the same place you would for any regular SELECT statement
SELECT TO_CHAR(...),
TO_NUMBER(...)
FROM random_table
WHERE TO_CHAR(...) = col1
AND TO_NUMBER(...) = col2
username and password are the results of the SQL statement. I'm guessing l_xmldoc is the input? There is not need to write something so simple as XQuery so what is your larger goal? If you provide a clearer example and question, we can help you better. -
TimeStamp to To_date format
Hi,
I am having the data like 09/09/2012 00:00:000 AM from the db itself, But i need to display only Date(mm/dd/yyyy) in report level. Is there any cast function to change to Date format or it can be achieved only through in database.
Regards,
GuruChange the Data type of the physical column from DATETIME to DATE.
please mark if helpful/correct
Regards,
Akansh Agarwal -
Labview 6 arbitrary function generator file format?
Hi,
I have old hardware (e.g. DAQcard1200) which I have to use with old versions of Labview (4 or 6) (as they run on "old" hardware - Pentium1 embedded boards with Win98 etc.). With Labview 8 I can load a file in .lvm format and use it as output for A0. But how is this with the "arbitrary function generator" from Labview 6 (benchtop.llb)? I constructed an arbitrary function manually within the vi and saved it to a file, but its format does not make sense - only "strange" characters are displayed, like dŸ¾ “£¾ˆt÷¾ VJ¾– ¾ ñ¾£úD¾ªÛ˜¾±¼ë¾¸ž, if I open the file with an editor...
Thanks!!
;-) TorstenI don't have LabVIEW 6.1, but if the example hasn't changed, then that example writes out a binary file, which is why you get all those "strange" characters. The file should be an array of SGL values. Thus, you can read it into LabVIEW using the Read From Binary File, and wiring an SGL constant to the "data type" input.
Attachments:
Example_VI_BD6.png 1 KB -
Match Regular Expression Function input string format
Hi,
I am new to labview and was having some difficulties using the Match Regular Experssion Function.
I am using labview to communicate with a sensor. I have installed the NI device driver to do so. The output of my sensor is in the format,
X20
R40 P20 A123. The numbers in this case are arbitrary. I am trying to use Match Regular Expression Function to display and perform mathematical operations on the numbers. I am having difficulties formatting the input string on the Match Regular Expression Function. Could you please give me some tips on how to format the example I provided.
ThankMoAgha wrote:
Hi,
I am new to labview and was having some difficulties using the Match Regular Experssion Function.
I am using labview to communicate with a sensor. I have installed the NI device driver to do so. The output of my sensor is in the format,
X20
R40 P20 A123. The numbers in this case are arbitrary. I am trying to use Match Regular Expression Function to display and perform mathematical operations on the numbers. I am having difficulties formatting the input string on the Match Regular Expression Function. Could you please give me some tips on how to format the example I provided.
Thank
Here is a way to do it if the format is constant (X R P A followed by a positive integer number).
Ben64 -
Frequency Response Function NxM output format
Hi,
When the Frequency Response Function for magnitude, phase, and coherence
is used in the NxM "all cross pairs" polymorphism, the format of the outputs
are still 1-D arrays of clusters instead of a 2-D NxM sized array of clusters.
Does anyone know how the indexing of this 1-D array would correspond to
indexing of the would be 2-D array? Or is it just [index/M, index%M].
Thanks,
KevinHi Kevin,
First, thanks for posting this request. You've helped us find a gap in our context help. The documentation on X-Y pairing should be improved and the VI documentation should be extended to cover all instances of this polymorphic VI. Here is some text that should be added to the "X-Y pairing" description:
"all cross pairs" means that the pairs are formed by matching each signal from array X with ALL signals from array Y, continuing in this fashion for each signal in X. If there are N signals in X and M signals in Y, the total number of cross pairs is N x M. The paired signal results Xchan-Ychan are returned in the order 1-1, ... 1-M, 2-1, ... 2-M, ... N-M. "
Hope this helps,
Mike C
LabVIEW Math & Signal Processing
National Instruments -
Offline market basket email functionality yielding nicely-formatted emails
I'm using htmlresources.zip contents in an InDesign folio to give some market basket functionality for customers working with sales reps. In the html/javascript/jquery code, I would like to allow the reps to send the basket info to the customers when they are ready, and I need the folio to work offline (so we’re not dependent on the internet for this app to function). The problem I am having is that mailto: does not appear to work using html tags in all the popular email clients (so I’m not using html tags), and the columns in the body of my email only line up if the customers email display is using mono-spaced fonts (which is not always the case—btw, tabs do not appear to work very well with mailto either). Hence, if our sales reps want the columns to line up nicely in the body of the email, I can only see a few options, namely: 1) stick with plain text mailto: issues, 2)write a separate XCode app to receive urls from the folio with all the email info included and then transmit those strings to a server-side mail server for transmission once internet connectivity is available, 3) somehow generate a pdf (to make the basket pretty, line up columns, include nice pictures, etc.) on the fly inside InDesign using Adobe api’s or using html5/javascript/jquery api’s and then include a link to that new pdf in the mailto: url or save the generated pdf off in the IPad somewhere. In the latter case, reps can then use the IPad to manually email the pdf themselves when they are ready. These are some things I’m working with and looking for some help in figuring out best methods. Thank you.
Moved to DPS forum.
-
How to use quarter format in "to_date()" function?
Hi,
I'm trying to use to_date() function with quarter format. How do I specify the format?
For example to convert '2002 quarter 1' using the to_date function.
I tried to_date('20021', 'YYYYQ'), and I got ORA-01820 cannot appear in date input format.
Please help, thank you!!!You cannot use Q when inputting data, only when retrieving data. When inputting, you must enter a valid date. Oracle has to store a date and if you just enter a quarter, it can't figure out what date to store. See the examples below:
SQL> -- test table:
SQL> CREATE TABLE test_table
2 (test_date DATE)
3 /
Table created.
SQL> -- the wrong way to input:
SQL> INSERT INTO test_table (test_date)
2 VALUES (TO_DATE ('2002-1', 'YYYY-Q'))
3 /
VALUES (TO_DATE ('2002-1', 'YYYY-Q'))
ERROR at line 2:
ORA-01820: format code cannot appear in date input format
SQL> -- the right way to input:
SQL> INSERT INTO test_table (test_date)
2 VALUES (TO_DATE ('27-OCT-2002', 'DD-MON-YYYY'))
3 /
1 row created.
SQL> -- to output:
SQL> COLUMN "Year and Quarter" FORMAT A16
SQL> SELECT test_date,
2 TO_CHAR (test_date, 'YYYY-Q') AS "Year and Quarter"
3 FROM test_table
4 /
TEST_DATE Year and Quarter
27-OCT-2002 2002-4
1 row selected. -
Dear All,
I need Output of the following query in the 'JANUARY' or 'JAN' i.e. 'MONTH' or 'MON' format. But following query is returning full date. Could any person help to get me output in MONTH or MON format but SQL should be using TO_DATE function.
TO_DATE(to_char(trunc(ORDERED_DATE),'MONTH'),'MONTH') order_date
Above query is failing to return desired output.
ThanksFor each DATE value, Oracle stores the following information: century, year, month, date, hour, minute, and second.
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements001.htm#sthref116
there are some conversion functions :
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions180.htm#i1009324
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions183.htm#i1003589
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions201.htm#i79761
moreover, the human eye can only read character datatypes (not number or date datytypes) !
which means, whenever you do a select sysdate from dual there will be an implicit conversion
to character datatype to make it readable for you (according to nls_date_format) .
alter session set nls_date_format = 'DD.MM.YYYY' ;
select sysdate today from dual ;
TODAY
21.12.2008
alter session set nls_date_format = 'YYYY.MM.DD' ;
select sysdate today from dual ;
TODAY
2008.21.12So the same statement select sysdate today from dual ; will give different results on different systems,
just depending on some initial settings !
You ask why ? It's because you are using implicit conversion !!!
Re: Sql Error
Maybe you are looking for
-
Hello all, I am trying to learn SAP Scripts. I have created one form named as 'zfm1' using SE71. Using SE 38 I have created a PRINT PROGRAM also which contains FM's like Open_form,Start_form,Write_form etc. When activated it is not displaying any err
-
Why is the .ini file deleted by iteself?
Hi all, I am working on a large program. It is really large and messy, but it works. The problem is sometimes it deletes .ini file by itself. This program uses a .ini file to keep all kinds of configurations. Sometimes when the program exits, it caus
-
I'm loading from Oracle 10g to Essbase. I have a new error that has popped up and would appreciate any help in how to debug it. org.apache.bsf.BSFException: exception from Jython: Traceback (innermost last): File "<string>", line 14, in ? AttributeEr
-
i used to have the ption to sent pics from my camera, but now i can't anymore, how can i reactivate this feature again?.
-
HT1657 After I rent a movie and it is down loaded how do you play it I don't see a play button
Where is the play button on this "upgraded" Itunes?