SQLite的转换“DD.MM.YYYY'格式化字符串到日期 [英] sqlite convert 'dd.MM.yyyy' formated String to date
问题描述
我有一个SQLite数据库在我的Android,蒙山日期时间列,包含日期的格式DD.MM.YYYY。 这不是我的数据库,我NIOT能够改变日期格式。 我想比较同一个字符串,这是重新presenting一个塞康日期数据库日期,但一切我tryed失败。 我怎么能这样列转换为有效的,compareable日期? 日期(),dattime()sdfttime()都返回NULL。
i have a sqlite database on my android, whith a datetime column, that contains a date with the Format dd.MM.yyyy. It's not my Database, I'm niot able to change the Dateformat. I want to compare the date in the database with a String, which is representing a secon date, but everything I tryed failed. How can I convert this column to a valid, compareable date? date(), dattime() sdfttime() everything returns NULL.
推荐答案
我搜索的谷歌sqlite3的日期DDMMYYYY和这个职位是最好的解决办法(这为我工作当中底部列出的职位只有一个):
I searched on google for "sqlite3 date ddmmyyyy" and this post is the best solution (and the only one that worked for me amongst the posts listed on the bottom):
问题:
一个SQLite表包含日期,格式为 DD / MM / YYYY
,需要转换为SQLite的原生格式 YYYY-MM-DD
Problem:
A SQLite table contains dates in the format DD/MM/YYYY
and need to be converted to SQLite native format YYYY-MM-DD
问题举例:
sqlite> select id, calendar_day from tbl1;
id;calendar_day
4248281;2011-06-19
4248282;2011-06-19
4248283;19/06/2011
4248284;19/06/2011
解决方案示例:
sqlite> update tbl1 set calendar_day = substr(calendar_day, 7) || "-" || substr(calendar_day,4,2) || "-" || substr(calendar_day, 1,2) where id>4248282;
结果举例:
sqlite> select id, calendar_day from tbl1;
id;calendar_day
4248281;2011-06-19
4248282;2011-06-19
4248283;2011-06-19
4248284;2011-06-19
感谢大家!
其他职位检查:
- <一个href="http://stackoverflow.com/questions/4428795/sqlite-convert-string-to-date/4429028#4429028">Sqlite字符串转换为日期
- SOLITE:日期格式SQLite中
- <一个href="http://stackoverflow.com/questions/3014667/how-can-i-convert-datetime-to-date-format-in-sqlite">How我可以转换日期时间为日期格式的源码
- sqlite的字符串转换为日期
- <一个href="http://stackoverflow.com/questions/4872657/how-to-convert-a-dd-mm-yyyy-date-format-string-into-a-yyyy-mm-dd-date-format-str">How转换一个DD-MM-YYYY日期格式的字符串转换成YYYY-MM-DD日期格式字符串或成Objective-C的一个的NSDate对象?
- Sqlite convert string to date
- SOLite:Date formatter in SQLite
- How can i convert datetime to date format in sqlite
- Sqlite convert string to date
- How to convert a DD-MM-YYYY date format string into a YYYY-MM-DD date format string or into a NSDate object in Objective-C?
这篇关于SQLite的转换“DD.MM.YYYY'格式化字符串到日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!