Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I convert datetime to date format in SQLite?

Tags:

sqlite

I want to show a date in DD-MM-YYYY format in a datagrid. By default, SQLite stores the data in date-time format. So how can I convert date-time format to date format in flex by using SQLite?

like image 202
Nidhi Avatar asked Jun 10 '10 13:06

Nidhi


People also ask

Does SQLite have date format?

The SQLite datetime function is a very powerful function that can calculate a date/time value, and return it in the format 'YYYY-MM-DD HH:MM:SS'.

How do I create a date field in SQLite?

First, create a new table named datetime_real . Second, insert the “current” date and time value into the datetime_real table. We used the julianday() function to convert the current date and time to the Julian Day. Third, query data from the datetime_real table.

How do I get today's date in SQLite?

The SQLite function DATE('now') returns the current date as a text value. It uses the 'YYYY-MM-DD' format, where YYYY is a 4-digit year, MM is a 2-digit month, and DD is a 2-digit day of the month. This function takes one argument: the text 'now' indicates the current date and time.


1 Answers

You can use strftime, from Date And Time Functions.

Example:

SELECT strftime('%d-%m-%Y', 'now')

output:

10-06-2010
like image 153
Nick Dandoulakis Avatar answered Oct 04 '22 13:10

Nick Dandoulakis