Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in SQL by (20.3k points)

I am trying to insert a datetime value into an SQLite database. It seems to be successful but when I try to retrieve the value there is an error:

<Unable to read data>

The SQL statements are:

create table myTable (name varchar(25), myDate DATETIME)

insert into myTable (name,mydate) Values ('fred','jan 1 2009 13:22:15')

1 Answer

0 votes
by (40.4k points)

You can try using the below format:

'2007-01-01 10:00:00'

i.e. yyyy-MM-dd HH:mm:ss

Note: Use the parameterized query as this frees you from worrying about the formatting details.

Related questions

0 votes
1 answer
asked Dec 12, 2020 in SQL by Appu (6.1k points)
0 votes
1 answer
asked Jul 11, 2019 in SQL by Tech4ever (20.3k points)
0 votes
1 answer
0 votes
1 answer
Welcome to Intellipaat Community. Get your technical queries answered by top developers!

28.4k questions

29.7k answers


94.1k users

Browse Categories