在Sqlite中将日期转换为字符串 [英] Convert a Date to a String in Sqlite

查看:236
本文介绍了在Sqlite中将日期转换为字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在 Sqlite 中将日期转换为字符串?例如,我试图在 Sqlite 中获取最小日期:

Is there a way to convert a date to a string in Sqlite? For example I am trying to get the min date in Sqlite:

SELECT MIN(StartDate) AS MinDate FROM TableName

我知道在 SQL Server 中我会使用下面的 SQL 来完成我想要做的事情:

I know in SQL Server I would use the SQL below to accomplish what I am trying to do:

SELECT CONVERT(VARCHAR(10), MIN(StartDate), 101) AS MinDate FROM TableName

谢谢!

推荐答案

试试这个:

SELECT MIN(DATE('your-date-here')) as MinDate FROM TableName

并确保您的日期遵循 SQLite 易于理解的格式(请参阅时间字符串. 文档中的部分)

And make sure your-date-here follows a well understood format by SQLite (See the Time String. section in the documentation)

这篇关于在Sqlite中将日期转换为字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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