SOLite:SQLite 中的日期格式化程序 [英] SOLite:Date formatter in SQLite

查看:13
本文介绍了SOLite:SQLite 中的日期格式化程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 SQLite 的初学者.我必须以 DD/MM/YYYY 格式插入和检索数据.在 Oracle 中有函数 TO_DATE(),TO_CHAR() 类似地,SQLite 中是否有任何日期格式化函数.

I am a beginner to SQLite. I have to insert as well as retrieve data in DD/MM/YYYY format. As in Oracle there are function TO_DATE(),TO_CHAR() similarly, are there any date formatter functions in SQLite.

我希望我的日期采用 DD/MM/YYYY 格式.

I want my date in DD/MM/YYYY format.

推荐答案

Sqlite 没有日期时间数据类型,因此它也没有任何 TO_DATETO_CHAR 函数.日期存储为字符串.

Sqlite does not have a datetime datatype, so it does not have any TO_DATE and TO_CHAR functions either. Dates are stored as strings.

一些函数用于日期和时间操作,它们使用ISO-8601 格式,因为在该格式中字典序排序对应于时间顺序排序,这不是你的格式的情况,所以如果你想要按日期排序,你必须使用iso格式.我还建议您使用 iso 格式,因为它没有歧义,而斜杠在 DD/MM/YYYY 格式和 MM/DD/YYYY 格式中都使用,会很快导致混淆.

There are some function for date and time manipulation, which use the ISO-8601 format, because in that format lexicographical sort corresponds to chronological sort, which is not the case of your format, so if you want to order by the dates, you have to be using the iso format. I'd also suggest you use the iso format because it's not ambiguous, while slashes are used in both DD/MM/YYYY format and MM/DD/YYYY format leading to confusion pretty quickly.

请注意,这些函数可以将 ISO 格式转换为您想要的任何格式,因此为了阅读,您可以拥有自己的格式,但似乎没有反函数,因此必须转换为 ISO 格式在您的应用程序代码中.

Note, that the functions can convert the ISO format to whatever format you want, so for reading, you can have your format, but there does not seem to be the inverse function, so converting to ISO format would have to be done in your application code.

这篇关于SOLite:SQLite 中的日期格式化程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆