Questions tagged [to-date]

to_date is sql function that converts string to date

to_date is an SQL function that converts a string to a date.

Reference

293 questions
1
vote
3 answers

convert date in 2015-05-09T09:00:12.123462000 to unix timestamp in hive

I want to convert the date which is in '2015-05-09T09:00:12.123462000' format to the unix timestamp in hive. The UNIX_TIMESTAMP('2015-05-09T09:00:12.123462000') doesn't work. I am not sure how i can convert this. I need this to compare two dates in…
user8066986
1
vote
1 answer

TO_DATE function is not working with timezone info.

I am trying below : SELECT TO_CHAR( TO_DATE('Wed May 18 00:00:00 IST 2016', 'DY MON DD HH24:MI:SS TZR YYYY'),'DD-MM-YYYY') FROM DUAL; and expecting 18-05-2016 But it says - 01821. 00000 - "date format not recognized" It works well if I remove IST…
Snehal Masne
  • 3,403
  • 3
  • 31
  • 51
1
vote
1 answer

OracleCommand seems to convert literal dates

I built a small query tool for Oracle using OracleCommand and OracleDataAdapter. Users just input a full query (no parameters), execute and the results are shown in a datagridview. So far so good, although I tried an invalid query, e.g.: SELECT *…
Koen
  • 3,626
  • 1
  • 34
  • 55
1
vote
1 answer

ORA-01830 error with to_date

I'm trying to create a date subtract two days and then convert it to a char. For some reason I'm getting the following error: ORA-01830: date format picture ends before converting entire input string Here's my code: SELECT…
i_am_so_stupid
  • 305
  • 3
  • 11
1
vote
2 answers

Convert timestamp to date data type

SELECT to_date(to_char(SYSTIMESTAMP, 'MM/DD/YYYY'), 'MM/DD/YYYY') FROM DUAL; ==> 04-MAR-16 Can anybody explain why this select statement doesn't result in '03/04/2016'? How can I write my selection so that it does result in this, as a date type? I…
Brian Brock
  • 357
  • 2
  • 3
  • 18
1
vote
1 answer

SQL trying to find amount of years since

I'm trying to find the years since a student enrolled. Question: Create a list of student names along with the number of years since they enrolled (round to 2 decimal places) for those students from area code 212. My code: SELECT first_name,…
user5948679
1
vote
5 answers

Date Format in Informatica

I am trying to convert a string to date in Informatica as follows TO_DATE('10/21/2014 0:00', 'MM/DD/YYYY MI:SS') but it throws an error for incorrect string. Can Informatica process this date format: MM/DD/YYYY MI:SS? If not, is there any…
1
vote
1 answer

Date format and getting results form last 24 hours

I am new to SQL and I am having an issue with the query below. I need to return the order sessions that were entered in the last 24 hours, the query returns all order sessions if I don't have the last statement in there, but I only need the ones…
1
vote
2 answers

Does TO_DATE function in oracle require strict format matching

I am confused with to_date(char[,'format'[,nls_lang]) function. Lets suppose I have to_date('31-DEC-1982','DD-MON-YYYY');should the format specified in the function be same as the date string? The above function works fine. When I use…
sandywho
  • 353
  • 1
  • 7
  • 16
1
vote
1 answer

Formatting a string to date

I have a date: 'Fri Jul 24 13:11:04 CEST 2015'. How can I convert this string to a date? Ultimately I would like to do something like that: to_char('Fri Jul 24 13:11:04 CEST 2015', 'DD/MM/YYYY HH24:MI:SS') I tried approaches but all failed so far…
kaligne
  • 3,098
  • 9
  • 34
  • 60
1
vote
3 answers

Formatting execute immediate with to_date ORACLE

Am stuck on a formatting procedure within a package..... script works ok however integrating it with a package is proving difficult!! Am not used to oracle...I have script running but not in package...well not all of it...Drop Table worked CREATE OR…
Ggalla1779
  • 476
  • 7
  • 18
1
vote
1 answer

Wrong conversion of date-string to date

When running these statements: select to_date('201103270100', 'YYYYMMDDHH24MI') from dual; select to_date('201103270130', 'YYYYMMDDHH24MI') from dual; I get these results: 27/3/2011 1:00:00 27/3/2011 1:30:00 which are correct. But when…
davidbe
  • 840
  • 1
  • 6
  • 16
1
vote
1 answer

Date comparison returns unusual result - SQL Oracle

I have a table of the structure: +---------+--------------+-----------------+---------------+-------+------+ | week_no | long_week_no | week_start_date | week_end_date | month | year…
Hawk
  • 5,060
  • 12
  • 49
  • 74
1
vote
4 answers

Convert string to date in Oracle SQL

I'm trying to convert string column to date in Oracle SQL. Here is my an example of value from the data: '03/12/14 11:00:00' Here is my query: select to_date(A,'DD/MM/YY HH24:MI:SS') from MyTable Here is an example of the output: 03-DEC-14 Why my…
Omri
  • 1,436
  • 7
  • 31
  • 61
1
vote
1 answer

Appending the HH:MI:SS to to_date function

I have a table in DB from which I take values from a date field.I store this date value in a cursor. currently the date value is of the format DD:MON:YY. Now I convert this date into character using to_char function so as to append time 00:00:00 to…
Arvind R.
  • 11
  • 2