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

263 questions
3
votes
3 answers

dd-mm-yyyy to yyyy-mm-dd SQL

I am working on SQL assignment in my school. There is a problem with DATE for me. There is a query given. INSERT INTO myTable (t_id, Birthdate) VALUES (1, TO_DATE('01-Jun-2005','dd-mm-yyyy')); INSERT INTO myTable (t_id, Birthdate) VALUES (2,…
KC Junior
  • 47
  • 6
3
votes
2 answers

How to convert a float column to datetime with only year and month in Python?

I have a DATE column like this, DATE CÓDIGO ... UNIDADE VALOR 0 2009.06 10000.0 ... NaN NaN 1 2009.06 10100.0 ... NÃO SE APLICA . 2 2009.06 10101.0 ... M2 0.46 3 2009.06 10102.0 …
3
votes
1 answer

Oracle DB to_date with year - to_date(2017,'YYYY') unexpected return

While writing few queries I needed to return only those rows that have date column set in this year (2017) , that's not my problem I know how to write this query in couple of diffrent ways, but I came across something strange and unexpected for me.…
3
votes
1 answer

ansi SQL date function in Oracle

I realize I could use a combination of to_char and to_date and what not as a work-around, but I'm trying to figure out why this doesn't work. I am using Oracle 12.1 select '2016-10-01' from dual union all select to_char(2016)||'-10-01' from…
fleetmack
  • 299
  • 1
  • 3
  • 10
3
votes
1 answer

PostgreSQL: Insert Date and Time of day in the same field/box?

After performing the following: INSERT INTO times_table (start_time, end_time) VALUES (to_date('2/3/2016 12:05', 'MM/DD/YYYY HH24:MI'), to_date('2/3/2016 15:05', 'MM/DD/YYYY HH24:MI')); PostgreSQL only displays the date. If possible, would I have…
gimmegimme
  • 191
  • 5
  • 20
3
votes
3 answers

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

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'…
Rishi Deorukhkar
  • 169
  • 2
  • 14
3
votes
4 answers

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

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',…
Dmitry Kompot
  • 55
  • 1
  • 7
3
votes
2 answers

Date and quarter SQL ORACLE

I am currently working on oracle sql and have some issues managing dates and quarters. The first thing I try to do is given a quarter and a year I would like to know the number of days of the quarter. For example, quarter 1 in 2013 had 90 days but…
Soji
  • 157
  • 1
  • 5
  • 16
3
votes
1 answer

ORA-01830: date format picture ends before converting entire input string in TOAD

I have a script in which I am writing functions and procedures. The script works absolutely fine in Oracle SQL developer without any errors or warnings. This script I have to provide to a client side customer. The customer user runs the same script…
Namrata
  • 43
  • 1
  • 1
  • 3
3
votes
2 answers

Skip Characters in Oracle TO_DATE function

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…
Ehryk
  • 1,781
  • 2
  • 24
  • 46
3
votes
0 answers

Converting a DateTime string in Rails with to_time to_datetime acts different. Why?

After deploying my rails app to a VPS I had some problems with 'time'. After some puzzling I found out that Rails is acting in a strange way when using the date/time conversion. My server is set to timezone "Amsterdam" and in the Rails config I…
MDekker
  • 413
  • 3
  • 16
3
votes
1 answer

Error in ToDate function in Pig

I have datetime data in my input and would like to load it correctly from Pig. I googled and learned it's suggested to load as chararray then covert to datetime with ToDate function. However, the same script works for one input but not another,…
user2830451
  • 1,474
  • 3
  • 18
  • 24
3
votes
2 answers

Oracle to_date with p.m./a.m

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…
3
votes
2 answers

postgresql cast numeric to date and format

I have my date field as numeric in postgresql and the values in the date are like 1401710352000 and when I try to convert it using to_timestamp(date) then I get the corresponding timestamp as "46388-06-07 10:40:00+00" I have tried to google it and…
Arif
  • 331
  • 2
  • 4
  • 16
3
votes
2 answers

Ruby string date to_date with try yields invalid date

I want to try get a date from params into a date format, and if it can't then i would like to then assign it to a date from a year today. This is what i tried. valid_until = params[:valid_until].try(:to_date) || Date.today.next_year The try method…
TheLegend
  • 11,612
  • 10
  • 54
  • 89
1
2
3
17 18