Sql query need for date format''Mon 23 Apr 16:45 pm'
i need SQL query to print date like 'Mon 23 Apr 16:45 pm' format
SQL> select to_char(sysdate,'Dy fmddfm Mon hh24:mi pm','nls_date_language=american') from dual
2 /
TO_CHAR(SYSDATE,'DY
Fri 27 Apr 13:04 pm
1 rij is geselecteerd.Regards,
Rob.
Similar Messages
-
Hi,
I am getting the following exception when i trying to insert data in to a table through a stored procedure.
oracle.apps.fnd.framework.OAException: java.sql.SQLException: ORA-01801: date format is too long for internal buffer
when execute this stored procedure from ana anonymous block , it gets executed successfully, but i use a OracleCallableStatement to execute the procedure i am getting this error.
Please let me know how to resolve this error.
Is this error something to do with the Database Configuration ?
Thanks & Regards
MeenalI don't know if this will help, but we were getting this error in several of the standard OA framework pages and after much pain and aggravation it was determined that visiting the Sourcing Home Page was changing the timezone. For most pages this just changed the timezone that dates were displayed in, but some had this ORA-01801 error and some others had an ORA-01830 error (date format picture ends before converting entire input string). Unfortunately, if you are not using Sourcing at your site, this probably won't help, but if you are, have a look at patch # 4519817.
Note that to get the same error, try the following query (I got this error in 9.2.0.5 and 10.1.0.3):
select to_date('10-Mar-2006', 'DD-Mon-YYYY________________________________________________HH24:MI:SS') from dual;
It appears that you can't have a date format that is longer than 68 characters. -
Input Value long enough for date format ,Error in executing parallel query
Hi,
My Table: ANML( ID, STATUS,B_DATE,B_MONTH,B_YEAR, DEATH_DATE)
status 1 for alive and 2 for dead.
i wrote a view to get age.
as
create or relace view view1 as
select top."ID",top."STATUS",top."DOB",top."DEATH_DATE",top."ANML_AGE",top."DAYSDIFF",
CASE
WHEN anml_age < 1
THEN 'D'
ELSE 'M'
END age_unit,
CASE
WHEN anml_age < 1
THEN TO_CHAR (daysdiff || ' Day(s)')
WHEN anml_age < 12
THEN TO_CHAR (anml_age || ' Month(s)')
WHEN MOD (anml_age, 12) = 0
THEN TO_CHAR (ROUND (anml_age / 12, 0) || ' Year(s) '
ELSE TO_CHAR ( ROUND (anml_age / 12, 0)
|| ' Year(s) '
|| MOD (anml_age, 12)
|| ' Month(s)'
END age_string
from
(SELECT a.*,
CASE WHEN status IN ( 1)
THEN FLOOR(MONTHS_BETWEEN(TRUNC(SYSDATE),dob))
WHEN death_date IS NOT NULL AND status IN (2)
THEN FLOOR(MONTHS_BETWEEN(death_date,dob))
END anml_age,
CASE WHEN status IN (1)
THEN FLOOR(TRUNC(SYSDATE)-TRUNC(dob))
WHEN death_date IS NOT NULL AND status IN (2)
THEN FLOOR(TRUNC(death_date) - TRUNC(dob))
END daysdiff
from (
SELECTanml.id, status,
TO_DATE ( DECODE (b_date,
NULL, 1,
b_date
|| '-'
|| DECODE (b_month,
NULL, 1,
b_month
|| '-'
|| b_year,
'dd-mm-yyyy'
) DOB,
death_date
FROM anml
WHERE b_year IS NOT NULL
) a) top
when i tried to fetch all values from view its working fine.
But when i tried to fetch values based on condition like as follows,
select * from view1 where anml_age > 20 and anml_age<30
I am getting error like:
Input Value long enough for date format and Error in executing parallel query
Please tell me wht is wrong.Here is your formatted code
create or relace view view1 as
select top."ID",top."STATUS",top."DOB",top."DEATH_DATE",top."ANML_AGE",top."DAYSDIFF",
CASE
WHEN anml_age < 1
THEN 'D'
ELSE 'M'
END age_unit,
CASE
WHEN anml_age < 1
THEN TO_CHAR (daysdiff || ' Day(s)')
WHEN anml_age < 12
THEN TO_CHAR (anml_age || ' Month(s)')
WHEN MOD (anml_age, 12) = 0
THEN TO_CHAR (ROUND (anml_age / 12, 0) || ' Year(s) '
ELSE TO_CHAR ( ROUND (anml_age / 12, 0)
|| ' Year(s) '
|| MOD (anml_age, 12)
|| ' Month(s)'
END age_string
from
(SELECT a.*,
CASE WHEN status IN ( 1)
THEN FLOOR(MONTHS_BETWEEN(TRUNC(SYSDATE),dob))
WHEN death_date IS NOT NULL AND status IN (2)
THEN FLOOR(MONTHS_BETWEEN(death_date,dob))
END anml_age,
CASE WHEN status IN (1)
THEN FLOOR(TRUNC(SYSDATE)-TRUNC(dob))
WHEN death_date IS NOT NULL AND status IN (2)
THEN FLOOR(TRUNC(death_date) - TRUNC(dob))
END daysdiff
from (
SELECTanml.id, status,
TO_DATE ( DECODE (b_date,
NULL, 1,
b_date
|| '-'
|| DECODE (b_month,
NULL, 1,
b_month
|| '-'
|| b_year,
'dd-mm-yyyy'
) DOB,
death_date
FROM anml
WHERE b_year IS NOT NULL
) a) top -
SQL Loader Problem with Date Format
Dear all,
I am dealing with a problem in loading data with SQL Loader. The problem is in the date format.
More specifically, I created the following Control File:
file.ctl
LOAD DATA
INFILE 'D:\gbal\chatium.log'
APPEND INTO TABLE CHAT_SL
FIELDS TERMINATED BY WHITESPACE
TRAILING NULLCOLS
(SL1 DATE "Mon DD, YYYY HH:MI:SS FF3AM",
SL2 char,
SL3 DATE "Mon DD, YYYY HH:MI:SS FF3AM",
SL4 char,
SL5 char,
SL6 char,
SL7 char,
SL8 char,
SL9 char,
SL10 char,
SL11 char,
SL12 char,
SL13 char,
SL14 char,
SL15 char)
The data we want to load are in the following file:
Apr 29, 2007 12:05:49 AM 1060615 Apr 29, 2007 12:05:35 AM 306978537730 24026384 chatium.user.userinfo WAP 0
Apr 29, 2007 12:12:51 AM 1061251 Apr 29, 2007 12:12:27 AM 306978537730 24026384 chatium.channel.list WAP 0
Apr 29, 2007 12:12:51 AM 1061264 Apr 29, 2007 12:12:32 AM 306978537730 24026384 chatium.channel.listdetail WAP 0
Apr 29, 2007 12:13:51 AM 1061321 Apr 29, 2007 12:13:31 AM 306978537730 24026384 chatium.user.search WAP 0
Apr 29, 2007 12:13:51 AM 1061330 Apr 29, 2007 12:13:37 AM 306978537730 24026384 chatium.user.userinfo WAP 0
The error log file is the following:
SQL*Loader: Release 9.2.0.1.0 - Production on Mon Apr 30 11:29:16 2007
Copyright (c) 1982, 2002, Oracle Corporation. All rights reserved.
Control File: file.ctl
Data File: D:\gbal\chatium.log
Bad File: chatium.bad
Discard File: none specified
(Allow all discards)
Number to load: ALL
Number to skip: 0
Errors allowed: 50
Bind array: 64 rows, maximum of 256000 bytes
Continuation: none specified
Path used: Conventional
Table CHAT_SL, loaded from every logical record.
Insert option in effect for this table: APPEND
TRAILING NULLCOLS option in effect
Column Name Position Len Term Encl Datatype
SL1 FIRST * WHT DATE MonDD,YYYYHH:MI:SS
SL2 NEXT * WHT CHARACTER
SL3 NEXT * WHT CHARACTER
SL4 NEXT * WHT CHARACTER
SL5 NEXT * WHT CHARACTER
SL6 NEXT * WHT CHARACTER
SL7 NEXT * WHT CHARACTER
SL8 NEXT * WHT CHARACTER
SL9 NEXT * WHT CHARACTER
SL10 NEXT * WHT CHARACTER
SL11 NEXT * WHT CHARACTER
SL12 NEXT * WHT CHARACTER
SL13 NEXT * WHT CHARACTER
SL14 NEXT * WHT CHARACTER
SL15 NEXT * WHT CHARACTER
Record 1: Rejected - Error on table CHAT_SL, column SL1.
ORA-01840: input value not long enough for date format
Record 2: Rejected - Error on table CHAT_SL, column SL1.
ORA-01840: input value not long enough for date format
Record 3: Rejected - Error on table CHAT_SL, column SL1.
ORA-01840: input value not long enough for date format
Record 4: Rejected - Error on table CHAT_SL, column SL1.
ORA-01840: input value not long enough for date format
I wonder if you could help me.
Thank you very much in advance.
Giorgos BaliotisSQL> select to_date('Apr 29, 2007 12:05:49 AM','Mon DD, YYYY HH:MI:SS FF3AM') from dual;
select to_date('Apr 29, 2007 12:05:49 AM','Mon DD, YYYY HH:MI:SS FF3AM') from dual
ERROR at line 1:
ORA-01821: date format not recognized
SQL> ed
Wrote file afiedt.buf
1* select to_date('Apr 29, 2007 12:05:49 AM','Mon DD, YYYY HH:MI:SS AM') from dual
SQL> /
TO_DATE(
29/04/07
SQL> Then, you defined blank space as separator, but there is spaces in your date inside your file. So, you should add double-quotes around the date field like below, and add optionally enclosed by '"' into your ctlfile.
"Apr 29, 2007 12:05:49 AM" 1060615 "Apr 29, 2007 12:05:35 AM" 306978537730 24026384 chatium.user.userinfo WAP 0
"Apr 29, 2007 12:12:51 AM" 1061251 "Apr 29, 2007 12:12:27 AM" 306978537730 24026384 chatium.channel.list WAP 0
"Apr 29, 2007 12:12:51 AM" 1061264 "Apr 29, 2007 12:12:32 AM" 306978537730 24026384 chatium.channel.listdetail WAP 0
"Apr 29, 2007 12:13:51 AM" 1061321 "Apr 29, 2007 12:13:31 AM" 306978537730 24026384 chatium.user.search WAP 0
"Apr 29, 2007 12:13:51 AM" 1061330 "Apr 29, 2007 12:13:37 AM" 306978537730 24026384 chatium.user.userinfo WAP 0Example :
http://download-uk.oracle.com/docs/cd/B19306_01/server.102/b14215/ldr_concepts.htm#sthref477
Nicolas. -
SQL query needed to identify cancelled invoice where distribution lines
SQL query needed to identify cancelled invoice where distribution lines Debit is not equal Credit line item in particular
Is there a way from back end FROM ap_invoice_distributions_all where we can find for the cancelled invoice where distribution lines Debit is not equal Credit line item
Regards,
Prakash RanjanHello Prakash
Can you please see if this query helps you?
SELECT i.invoice_id, i.invoice_amount, nvl(sum(d.amount),0)
FROM ap_invoice_distributions_all d, ap_invoices_all i
WHERE i.org_id = <you org_id>
AND i.invoice_id = d.invoice_id
AND d.line_type_lookup_code not in ('PREPAY')
AND i.cancelled_date IS NOT NULL
GROUP BY i.invoice_id, i.invoice_amount
HAVING (i.invoice_amount <> nvl(sum(d.amount),0))
ORDER BY i.invoice_id asc
Octavio -
How to declare data type for DATE format
Hi,
I need the data format in this format DD-MM-YYYY HH:MI:SS
So, I m using select TO_CHAR(Date_Column, 'DD-MM-YYYY HH:MI:SS') from dual;
Now, In my procedure I need to assign this to a OUT variable, what should be the Data type of out variable.
My OUT variable is used by other program.
ThanksYou can use VARCHAR2. Try the below
CREATE OR REPLACE PROCEDURE proc_test(p_indate DATE, p_outdate OUT VARCHAR2)
AS
BEGIN
p_outdate:= TO_CHAR(p_indate,'DD-MON-YYYY HH:MI:SS');
END;
SET SERVEROUTPUT ON
DECLARE
v_date VARCHAR2(50);
BEGIN
proc_test(SYSDATE,v_date);
DBMS_OUTPUT.PUT_LINE(v_date);
END;
OUTPUT:-
anonymous block completed
15-JAN-2014 12:13:46 -
Basic SQL query scripts for SAP B1
hi guys,
do you have any documents, guides or reference links regarding basic SQL query scripts for SAP B1?
thanks and have a nice day!
blake p.Hi
You can also check SBONotes.com.
For sql understanding , you can search in websearch - tsql and it will pop up with informations you need.
You can also refer to forum once you understand the basic techniques
Hope this helps
Bishal -
How will write SQL query to fetch data from each Sub-partition..
Hi All,
Anyone does have any idea about How to write SQL query to fetch data from Sub-partition.
Actually i have one table having composite paritition(Range+list)
Now if i want to fetch data from main partition(Range) the query will be
SELECT * FROM emp PARTITION(q1_2005);
Now i want to fetch data at sub-partition level(List) .But i am not able to get any SQL query for that.
Pls help me to sort out.
Thanks in Advance.
AnwarSELECT * FROM emp SUBPARTITION(sp1);
-
How to run recordset SQL query in FORM DATA event
How can I run recordset SQL query in FORM DATA event upon clicking on Add button in the document?
Hi Slamet,
When you receive a form data event you have a class containing inside it a ObjectKeys xml info regarding the object added/modified,...
With the objects keys you can then use the DI API method called GetByKeys to obtain the DI Object.
There is some information about it in the SDK Help file, mainly in the "FormDataEvent" class definition:
<i>The event provides the unique ID (BusinessObjectInfo.ObjectKey) of the modified business object. You can use the value of this property as an input parameter in the DI API DataBrowser.GetByKeys method to get a DI object.</i>
Pay attention you don't have this information in the Before=True event of the Add as it is not yet in the database.
Hope it helps
Trinidad. -
NEED ALTER TABLE ALTER COLUMN FOR DATE FORMAT
Need something like this :
ALTER TABLE ABC
ALTER COLUMN DATE1 AS (DD/MM/YYYY)
need to appear in this format (29/03/2014) in the table.
also needs to be recorded in DB in that format.changed system date format, works. Thanks!
You should always store values as dates itself in date/datetime related field in SQLServer
The formatting can very easily be done in your front end (presentation layer) using format function
Even in T-SQL you can use CONVERT or FORMAT functions to get the date values in the format you want
Please Mark This As Answer if it solved your issue
Please Mark This As Helpful if it helps to solve your issue
Visakh
My MSDN Page
My Personal Blog
My Facebook Page
I don't follow you? Anyway, Olaf Helper's answer was the solution.
SQL Server has a data type called DATETIME. To correctly query dates, it is easier to use this as it allows the SQL engine to do all the calculations for you, also the canonical format for dates in any database language is YYYY-MM-DD, this ensures correctly
tiered dates that are stored in the right order. The way you store data and the way you display it should be kept as two seperate entities. This is the ISO standard and has been thoroughly investigated ...alot to say the least. This is where the term "front-end"
and "back-end" developers come from, and also the distinction between server-side and client-side scripting.
To cut a long story short, take the advice of the multiple professionals here, and follow standards otherwise you'll find yourself stuck, or worse, your legacy code will make someone tear their hair out. -
Need a SCCM SQL Query Report for Installed Software with Packages and Applications.
I need a report that will show the number of installs of all of the workstations applications and packages over a given period of time.
This will let us know how effective our deployments are and how well the on-demand software is being adopted.
Any help?Your Install Source might be an option as most SCCM deployments will install from C:\Windows\ccmcache\xx [where xx is a random folder name]. Most software vendors will put an install source in the registry, but not all do, so it won't be completely accurate.
When software is installed manually, the install source path won't be C:\Windows\ccmcache\xx.
Here is a SQL query I have for Install Source:
SELECT v_GS_COMPUTER_SYSTEM.Name0 as 'Computer Name', v_GS_INSTALLED_SOFTWARE.ProductName0 as 'Software Title', v_GS_INSTALLED_SOFTWARE.InstallSource0 as 'Install Source', v_GS_INSTALLED_SOFTWARE.ProductVersion0 as 'Version', v_GS_INSTALLED_SOFTWARE.InstalledLocation0
as 'Installed Location', v_GS_INSTALLED_SOFTWARE.InstallDate0 as 'Install Date'
FROM v_GS_COMPUTER_SYSTEM INNER JOIN v_GS_INSTALLED_SOFTWARE ON v_GS_COMPUTER_SYSTEM.ResourceID = v_GS_INSTALLED_SOFTWARE.ResourceID
WHERE v_GS_INSTALLED_SOFTWARE.ProductName0 like '%Office 365 Pro%'
ORDER BY v_GS_COMPUTER_SYSTEM.Name0 -
Why does Oracle SQL query returning a date field without the time component
Hi,
I'm a novice SQL user & hv just installed Oracle SQL developer (Version 3.0.04, Build MAIN-04.34).
I made the same SQL query using "Oracle SQL developer" & "TOAD for Oracle 9.0.1" but I got 2 different format on the same date field:
On TOAD, I get the date field extracted as *04/26/2011 23:12:58*
On Oracle, I get the date field extracted as *26/APR/11*
Why is the Oracle result in a different format & missing the time component?
Is there any option/preference that I need to set in Oracle SQL developer to get the full date/time format displayed?
I've tried to set my the date format to DD/MON/RR HH12:MI:SSXFF AM under the preference -> database NLS but I still get the same format!
Plse help!hokim wrote:
Hi,
I'm a novice SQL user & hv just installed Oracle SQL developer (Version 3.0.04, Build MAIN-04.34).
I made the same SQL query using "Oracle SQL developer" & "TOAD for Oracle 9.0.1" but I got 2 different format on the same date field:
On TOAD, I get the date field extracted as *04/26/2011 23:12:58*
On Oracle, I get the date field extracted as *26/APR/11*
Why is the Oracle result in a different format & missing the time component?
Is there any option/preference that I need to set in Oracle SQL developer to get the full date/time format displayed?
I've tried to set my the date format to DD/MON/RR HH12:MI:SSXFF AM under the preference -> database NLS but I still get the same format!
Plse help!http://edstevensdba.wordpress.com/category/nls_date_format/ -
How to write a sql query to retrieve data entered in the past 2 weeks
Hi,
I have file names and last accessed date(java.sql.Date format) stored in my database table, I would like to know how I can write a query to get the name of files accessed in the past 2 weeks,I use open sql server at the back end.
Thanks in advance.This has essentially nothing to do with JDBC. JDBC is just an API to execute the SQL language using Java and thus interact with the databases.
Your problem is related to the SQL language, you don't know how to write the SQL language. I suggest you to go through a SQL tutorial (there is one at w3schools.com) and to read the SQL documentation which come along with the database in question. A decent database manfacturer has a website and probably also a discussion forum / mailinglist as well.
I'll give you a hint: you can just use equality operators in SQL like everywhere. For example: "WHERE date < somedate". -
Hi All,
I have belwo two record values.
select 1 as seq_no,'test1' as data_set from dual
union
select 1,'12test' from dual
union
select 2,'abcd' from dual
union
select 2,'ilm' from dual
union
select 2,'12test444' from dual
here i need to extract the below o/p from from the above dataset
1,12test
1,test1
2,12test444
select 1 as seq_no,'test1' as data_set from dual
union
select 1,'12test' from dual
union
select 2,'abcd' from dual
union
select 2,'ilm' from dual
here i need to extract the below o/p from from the above dataset
1,12test
1,test1
2,abcd
2,ilm
The logic behind the above two types of o/p is
if the search string 'test' is present in any data set (data set is defined by same seq_no values) then print the whole row containing the search string. As in the first record value data set with seq_val 1 and 2 both have test string 'test' , o/p is all the rows contating the search string 'test'
If the search string 'test' is not present in any data set (data set is defined by same seq_no values) then print all other rows not containing the search string. As in the second record value data set with seq_val 2 both doesn't have test string 'test' , o/p is all the rows not contating the search string 'test' in data test with seq_val 1as well as all the rows contating the search string 'test' in data set with seq_val 2
Hope i could explain my o/p logic and i need to perform this in a sql query.
Waiting for your responses.
Thanks in advance.Hi,
Here's one way:
WITH got_rnk AS
SELECT seq_no, data_set
, DENSE_RANK () OVER ( PARTITION BY seq_no
ORDER BY CASE
WHEN INSTR (data_set, 'test') > 0
THEN 1
ELSE 2
END
) AS rnk
FROM table_x
SELECT seq_no, data_set
FROM got_rnk
WHERE rnk = 1
;The CASE expression returns 1 if data_set contains 'test', and it returns 2 if it does not. Let's call this number x.
You're not really interested in x itself. Rather, you want all the rows that have the lowest value of x among rows with the same seq_no. That is, if any row with a given_seq_num has x=1, then you want all rows with that seq_no and x=1, but it the lowest x for the a seq_no is 2, then you want the rows with x=2 instead.
DENSE_RANK returns the the number 1 if the given riow is the lowest (or tied for the lowest) in its partition, so if the are any rows with x=1 in the group, rnk=1 will correspond to x=1. But if all the rows with the same seq_no have x=2, then rnk=1 will correspond to x=2. -
SQL Query Posting the Data Properly but Generating An Error
I've created a SQL query to update records in a database. While testing I used an Access database and it worked perfectly. To go into production I've moved the data to SQLServer 2005 installed on my xMII server. The SQL syntax is different for handling dates between the two databases so I modified my queries accordingly. I now have:
UPDATE ControlLimits SET Metric_ID='[Param.1]', CDate='[Param.2]', LCL=[Param.3], Mean=[Param.4], UCL=[Param.5]
Where (Metric_ID='[Param.1]' and CDate = '[Param.2]')
CDate is my date field being passed in the format 'mm/dd/yyyy', the table field is formatted for datetime - the same as in Access.
When running this query (with the [Param.x]'s being replaced with actual values)through SQL Server Management Studio on the xMII server, it works just fine. When run as a query template, the data is posted properly to the table but the template returns a 'A SQL Error has occurred on query, The statement did not return a result set..'
Any ideas?
DavidUdayan,
You are absolutely correct! When I did it in Access I was correctly using the Command mode. When I moved to the SQL Server data source in my query template, I picked the Fixed Query mode by mistake.
Thanks for your help!
Regards,
David
Maybe you are looking for
-
How to use the report 'CRM_TEST_ORDER_MAINTAIN,?
Hi Experts, I have a scenario where I need to add a new partner in place of an old one in an order. I have seen the code in the report 'CRM_TEST_ORDER_MAINTAIN'. I am trying to use that . But i found that it always creates a new record in the '
-
Transfer Data from Palm OS to BlackBerry 10 Smartphones - US
(I am Posting this a 2nd time because I'm not sure it went through the first time; got some kind of authenication error message.) - 1. What is the best way to transfer my PIM Organizer Data from my Palm TX to a BlackBerry Z10? - 2. How do I obtain t
-
After creating a MovieClips symbol in flash CS3 and converting it to flex component, I succeeded in exporting it to SWC and included it in the flex mxml file. However, when I run the applications, the MovieClips failed to display. Did anyone have sim
-
Can't access CMC and infoview on BO edge series 3.1
Hello gurus, I have just installed BO edge series 3.1, immediate moment after installation, I can open CMC console, but after I 've done other operation on the computor, CMC can't open now, also I can't open infoview, error shows " can't esta
-
Regarding idoc segments modifcation
Hi, I created a segment zdh_name in we31. Then i released the idoc segment. Also i created a corresponding idoc type and released it and also created a message type . When an idoc is created for a Purchase order in me21n the segment e1edp