Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert String to Date in Informix DB

Tags:

sql

informix

I need to Convert a string say '12/12/2013 14:30:56.583' to be converted in Date Format like 2013-12-12 14:30:56.583 in Informix database.

I Used following function

to_date('12/12/2013 14:30:56.583',"%d/%m/%Y %H:%M:%S.")    

But its not accepting Milliseconds , Milliseconds are important to the resulting value.

like image 345
user2760011 Avatar asked Jan 14 '14 20:01

user2760011


People also ask

How do I get current date in Informix?

Informix provides the CURRENT [ q1 TO q2 ] operator, to get the system date/time on the server where the current database is located. When no qualifiers are specified, CURRENT returns a DATETIME YEAR TO FRACTION(3) .

What is To_date function?

The TO_DATE function accepts an argument of a character data type and converts this value to a DATETIME value. The TO_DATE function evaluates a character string according to the date-formatting directive that you specify and returns a DATETIME value.


1 Answers

The database version is important. The behaviour of %F was recently (11.70.xC8 and 12.10.xC2) changed. In previous versions the "." dot must probably be omitted as well as the "n" qualifier. Regards

like image 90
Fernando Nunes Avatar answered Sep 27 '22 21:09

Fernando Nunes