to-date

Oracle to_date with p.m./a.m

一曲冷凌霜 提交于 2019-12-02 00:31:18
I need to convert a string into a Date in oracle. The format of the string is like this: '08/11/1999 05:45:00 p.m.' But the last position can change p.m or a.m. I tried to do some like: to_date('08/11/1999 05:45:00 p.m.', 'dd/mm/yyyy hh:mi:ss a.m./p.m.') to_date('08/11/1999 05:45:00 p.m.', 'dd/mm/yyyy hh:mi:ss am/pm') But return me an error ORA-01855 : AM/A.M. or PM/P.M. required... any idea ? Try this: to_date ( '08/11/1999 05:45:00 p.m.' , 'dd/mm/yyyy hh:mi:ss a.m.' , 'nls_date_language=american' ) It seems that "a.m." and "p.m." rather than "am" and "pm" require nls_date_language to be set

Oracle to_date function. Mask needed

旧城冷巷雨未停 提交于 2019-12-01 17:19:36
I have string of date from xml file of such kind: '2010-09-09T22:33:44.OZ' I need to extract only date and time. I want to ignore symbol T and .OZ (time zone). Which mask I should use? Thanks in advance select TO_DATE('2010-09-09T22:33:44.OZ' ,'YYYY-MM-DD"T"HH24:MI:SS".OZ"') from dual; 9/09/2010 10:33:44 PM If the timezone information is needed: select to_timestamp_tz('2010-09-09T22:33:44.GMT','YYYY-MM-DD"T"HH24:MI:SS.TZR') from dual; 09-SEP-10 22.33.44.000000000 GMT But OZ isn't a recognised timezone abbreviation, so you'd need to do some pre-conversion of that to something that is. If you

Oracle to_date function. Mask needed

◇◆丶佛笑我妖孽 提交于 2019-12-01 16:16:58
问题 I have string of date from xml file of such kind: '2010-09-09T22:33:44.OZ' I need to extract only date and time. I want to ignore symbol T and .OZ (time zone). Which mask I should use? Thanks in advance 回答1: select TO_DATE('2010-09-09T22:33:44.OZ' ,'YYYY-MM-DD"T"HH24:MI:SS".OZ"') from dual; 9/09/2010 10:33:44 PM 回答2: If the timezone information is needed: select to_timestamp_tz('2010-09-09T22:33:44.GMT','YYYY-MM-DD"T"HH24:MI:SS.TZR') from dual; 09-SEP-10 22.33.44.000000000 GMT But OZ isn't a

Convert text to timestamp in redshift

痞子三分冷 提交于 2019-12-01 03:54:33
I have a text field "presence_changed_at" with text values i.e. '2014/12/17 08:05:28 +0000 . I need to convert this into timestamp. In postgreSQL there is function TO_TIMESTAMP() , however in redshift this does not seem to be supported. I can get the date without time by TO_DATE("presence_changed_at",'YYYY/MM/DD HH24:MI:SS') which produces 2014-12-12 but i can't find any way to get TIMESTAMP format. Thanks in advance for solving this try convert function: convert(timestamp,presence_changed_at) It's surprisingly horrible to get a datetime from a unixtime in redshift without a subselect. However

Convert text to timestamp in redshift

℡╲_俬逩灬. 提交于 2019-11-30 03:26:28
问题 I have a text field "presence_changed_at" with text values i.e. '2014/12/17 08:05:28 +0000 . I need to convert this into timestamp. In postgreSQL there is function TO_TIMESTAMP() , however in redshift this does not seem to be supported. I can get the date without time by TO_DATE("presence_changed_at",'YYYY/MM/DD HH24:MI:SS') which produces 2014-12-12 but i can't find any way to get TIMESTAMP format. Thanks in advance for solving this 回答1: try convert function: convert(timestamp,presence

Using Oracle to_date function for date string with milliseconds

微笑、不失礼 提交于 2019-11-28 21:02:33
I have to perform some inserts into an Oracle DB. I have some dates in the following format '23.12.2011 13:01:001' Following the documentation I wrote inserts to_date as follows: to_date('23.12.2011 13:01:01', 'DD.MM.YYYY HH24:MI:SS') which works properly. Now I have dates with milliseconds with the format '23.12.2011 13:01:001' I've tried the following: to_date('23.12.2011 13:01:001', 'DD.MM.YYYY HH24:MI:SSFF3') which is incorrect (delivers an error 01821. 00000 - "date format not recognized"). Which "String" should I use for this format with milliseconds? Thanks in advance! An Oracle DATE

Date comparison returns unusual result - SQL Oracle

China☆狼群 提交于 2019-11-27 15:54:22
I have a table of the structure: +---------+--------------+-----------------+---------------+-------+------+ | week_no | long_week_no | week_start_date | week_end_date | month | year | +---------+--------------+-----------------+---------------+-------+------+ | 1 | 1A | 01/01/2015 | 03/01/2015 | JAN | 2015 | | 1 | 1B | 04/01/2015 | 10/01/2015 | JAN | 2015 | | 2 | 2 | 11/01/2015 | 17/01/2015 | JAN | 2015 | | 3 | 3 | 18/01/2015 | 24/01/2015 | JAN | 2015 | | .. | .. | .. | .. | .. | .. | | 51 | 51 | 14/12/2014 | 20/12/2015 | DEC | 2014 | +---------+--------------+-----------------+--------------

Using Oracle to_date function for date string with milliseconds

你说的曾经没有我的故事 提交于 2019-11-27 12:39:43
问题 I have to perform some inserts into an Oracle DB. I have some dates in the following format '23.12.2011 13:01:001' Following the documentation I wrote inserts to_date as follows: to_date('23.12.2011 13:01:01', 'DD.MM.YYYY HH24:MI:SS') which works properly. Now I have dates with milliseconds with the format '23.12.2011 13:01:001' I've tried the following: to_date('23.12.2011 13:01:001', 'DD.MM.YYYY HH24:MI:SSFF3') which is incorrect (delivers an error 01821. 00000 - "date format not recognized

how to display number value in words

谁都会走 提交于 2019-11-27 08:13:49
问题 Q. Display the number value in Words and output should look like this SAL In_Words --------- ----------------------------------------------------- 800 eight hundred 1600 one thousand six hundred 1250 one thousand two hundred fifty And, I'm still didn't figure out, how this query is the solution for the above output. select sal, to_char(to_date(sal,'j'),'Jsp') in_words from emp What to_date is doing here ? Anyone have any idea about this query ? 回答1: So how the query works? Well here’s why:

String to date in Oracle with milliseconds

六月ゝ 毕业季﹏ 提交于 2019-11-27 08:03:05
I want to convert the follow string to date: 2004-09-30 23:53:48,140000000 I tried: to_date('#', 'YYYY-MM-DD HH24:MI:SS,FF9') But PL/SQL keep throwing this error: ORA-01821: date format not recognized. FF9 is incorrect for Oracle, any suggestion? Oracle stores only the fractions up to second in a DATE field. Use TIMESTAMP instead: SELECT TO_TIMESTAMP('2004-09-30 23:53:48,140000000', 'YYYY-MM-DD HH24:MI:SS,FF9') FROM dual , possibly casting it to a DATE then: SELECT CAST(TO_TIMESTAMP('2004-09-30 23:53:48,140000000', 'YYYY-MM-DD HH24:MI:SS,FF9') AS DATE) FROM dual I don't think you can use