Reputation: 792
I m developing android application. I need to convert datetime
into date.
I want to convert '25-07-2013 11:44AM'
(datetime) into '25-07-2013'
(date).
I am trying this function to convert SELECT date('25-07-2013 11:44AM')
, but it was not working.
Please suggest some solution for this problem.
Upvotes: 0
Views: 557
Reputation: 154
I am not sure if you are search for Java code or SQL code , but if it is Java code then solution could be this :
String date = "25-07-2014 11:44AM";
SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
String newDate = dateFormat.format(dateFormat.parse(date));
System.out.println(newDate);
If in case your are looking for SQL code let me know I will share that as well.
Upvotes: 0
Reputation: 46963
According to this page, it does not seem that am/pm times are supported in date
SQLite function (this should be noted as h
or K
according to the date format specification of Java at least; also it is explicitly mentioned %H hour: 00-24
). Maybe experiment if using 24 hour clock will not trigger the issue.
Upvotes: 3