How to change SQLite time format datetime
I am trying to get the date from SQLite. I am getting timestamp in coredata, but I need to see the date. What is the command to get the 开发者_运维百科timestamp converted into YYYY-MM-DD format? My query is:
SELECT ZDATE FROM ZWEATHER
Zdate is datetime.
You may be looking for the DATE()
function, as seen in the SQLite manual:
SELECT date(ZDATE);
The first thing to understand is that SQLite has no date type. It has no time type either.
It only offers some time functions. The page Piskvor links to is what you need. You enter the date and/or time in your database as a string following one of a few formats available:
- YYYY-MM-DD
- YYYY-MM-DD HH:MM
- YYYY-MM-DD HH:MM:SS
- YYYY-MM-DD HH:MM:SS.SSS
- YYYY-MM-DDTHH:MM
- YYYY-MM-DDTHH:MM:SS
- YYYY-MM-DDTHH:MM:SS.SSS
- HH:MM
- HH:MM:SS
- HH:MM:SS.SSS
Or as a floating point value representing the Julian day number.
精彩评论