to-date

Strings with TO_DATE command as value on the database

孤街浪徒 提交于 2020-01-07 13:37:38
问题 I have a problem and I can't solve it yet. On my database I have the string: TO_DATE(' 2015-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'). So when I'm building my query it is like the following: Select my_field FROM my_table. the result is: TO_DATE(' 2015-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN') Get it? How to I extract the value of this field as a command statement on a select query? 回答1: On the sqlplus command line, if your system supports

Not a valid month in oracle when add_months is used

元气小坏坏 提交于 2020-01-05 01:11:11
问题 I have given the below code in query. where to_date(cal_wid,'yyyymmdd') between add_months(to_date(sysdate, 'MM-YYYY'),-12) and to_date(sysdate, 'MM-YYYY') I am getting the following bug. (I am doing in a Xampp server) Warning: oci_execute(): ORA-01843: not a valid month in C:\xampp\htdocs\xxx\index.php on line 149 Warning: oci_fetch_array(): ORA-24374: define not done before fetch or execute and fetch in C:\xampp\htdocs\xxx\index.php on line 160 Can anyone tell why I am getting this error?

Not a valid month in oracle when add_months is used

爱⌒轻易说出口 提交于 2020-01-05 01:10:03
问题 I have given the below code in query. where to_date(cal_wid,'yyyymmdd') between add_months(to_date(sysdate, 'MM-YYYY'),-12) and to_date(sysdate, 'MM-YYYY') I am getting the following bug. (I am doing in a Xampp server) Warning: oci_execute(): ORA-01843: not a valid month in C:\xampp\htdocs\xxx\index.php on line 149 Warning: oci_fetch_array(): ORA-24374: define not done before fetch or execute and fetch in C:\xampp\htdocs\xxx\index.php on line 160 Can anyone tell why I am getting this error?

Oracle Get only time from To_Date() in a Query?

大憨熊 提交于 2019-12-24 01:56:20
问题 I have an insert query: INSERT INTO THE_TABLE (Field_A) VALUES (TO_DATE('08/12/2011 08:35:42 AM','HH:MI:SS PM')) WHERE Something = 'SomethingElse' Field_A is a Date field. When I execute the query, Field_A still shows a date and time. Is there a way to grab only the time? I have tried To_Char(), but then it converts to a string and the field wont take it. I have also tried TO_DATE('08:35:42 AM','HH:MI:SS PM') and that doesn't work either, it still shows a date and time in the table. 回答1: If

Skip Characters in Oracle TO_DATE function

家住魔仙堡 提交于 2019-12-23 21:26:07
问题 I'm importing data that has SQL Server formatted dates in a .tsv ( yyyy-mm-dd hh24:mi:ss.mmm ) into an Oracle database using SQL Developer's Import Data wizard. How can I ignore the .mmm characters for importing them into a DATE column? I cannot seem to find an answer to this; I get that DATE columns don't hold milliseconds, but why can't I ignore specific patterns in the TO_DATE call? Also note that because I'm not generating the TO_DATE calls, I cannot SUBSTRING or otherwise manipulate the

ORA-01839 “date not valid for month specified” for to_date in where clause

醉酒当歌 提交于 2019-12-23 15:44:36
问题 I have following query ( BOCRTNTIME - varchar e.g 2015-02-28 12:21:45, VIEW_BASE_MARIX_T - some view ): select BOCRTNTIME from VIEW_BASE_MARIX_T where to_date(substr(BOCRTNTIME,1,10),'YYYY-MM-DD') between (to_date ('2016-01-01', 'YYYY-MM-DD')) and (to_date ('2016-02-01', 'YYYY-MM-DD')) On executing I get error: ORA-01839: "date not valid for month specified" I thought that there are can be incorrect data in BOCRTNTIME , so execute following query: select distinct substr(BOCRTNTIME,1,8),

oracle insert only time [duplicate]

北战南征 提交于 2019-12-17 10:02:22
问题 This question already has answers here : How to store only time; not date and time? (5 answers) Closed 5 years ago . I would like to insert data to db as time, not date. If I use to_date('2012-08-31 07:39:33', 'YYYY-MM-DD HH24:MI:SS') it adds date too. If I use to_date('09:34:00', 'HH24:MI:SS') it adds year, month, day as well, from nowhere :| Later I need to get rows where time is between x and y, not taking in account the year, month or day. How do I do that? thanks 回答1: A DATE type always

java.sql.SQLException: ORA-01843: not a valid month error

梦想与她 提交于 2019-12-13 08:07:39
问题 I am getting date in html 5 input type = "date" format..in mm/dd/yyyy format. Then I am getting it String fDate = request.getParameter("fromDate"); room.setFromDate(fDate); Then while trying to run query insert into tbl_room_under_maintenance(room_id,room_number,from_date,to_date) values(?,?,to_date(?,'MM/DD/YYYY'),to_date(?,'MM/DD/YYYY')) PS1.setString(3,room.getFromDate().trim()); PS1.setString(4,room.getToDate().trim()); it shows error : java.sql.SQLException: ORA-01843: not a valid month

How to find a specific mask within a string - Oracle?

左心房为你撑大大i 提交于 2019-12-13 06:06:49
问题 I have a field in a table that can be informed with differente values. Examples: Row 1 - (2012,2013) Row 2 - 8871 Row 3 - 01/04/2012 Row 4 - 'NULL' I have to identify the rows that have a string with a date mask 'dd/mm/yyyy' informed. Like Row 3, so I may add a TO_DATE function to it. Any idea on how can I search a mask within the field? Thanks a lot 回答1: Sounds like a data model problem (storing a date in a string). But, since it happens and we sometimes can't control or change things, I

TO_CHAR and TO_DATE giving different results.How to achieve the TO_CHAR functionality using TO_DATE?

浪子不回头ぞ 提交于 2019-12-12 13:25:10
问题 SELECT TO_CHAR((select logical_date -1 from logical_date where logical_date_type='B'),'DD/MM/YYYY HH24:MI:SS') FROM DUAL; This Query returns 23/04/2016 00:00:00 o/p of select logical_date -1 from logical_date where logical_date_type='B' :4/23/2016 SELECT TO_DATE((select logical_date -1 from logical_date where logical_date_type='B'),'DD/MM/YYYY HH24:MI:SS') FROM DUAL; This Query returns 4/23/0016 . How do I get the format given by TO_CHAR using TO_DATE ?? 回答1: Dates do not have any intrinsic