欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 健康 > 养生 > Sqlite_Datetime列选择三月的行

Sqlite_Datetime列选择三月的行

2024/10/25 6:23:17 来源:https://blog.csdn.net/TuringSnowy/article/details/142407051  浏览:    关键词:Sqlite_Datetime列选择三月的行

In SQLite, use the strftime function to extract components from a date/time value

SELECT *
FROM table
WHERE strftime('%m', datemonth) = '03';

strftime(‘%m’, datemonth): extracts the month part from the datemonth column as a string (with leading zeros for single-digit months).

It is string from time.

strftime 方法按照 “%Y-%m-%d %H:%M:%S” 格式将日期和时间格式化为字符串并打印

strftime 是 python 的方法

now = datetime.now() # current date and timeyear = now.strftime("%Y")
print("year:", year)

year: 2020

strptime:
p表示parse,表示分析的意思,所以strptime是给定一个时间字符串和分析模式,返回一个时间对象
strftime:
f表示format,表示格式化,和strptime正好相反,要求给一个时间对象和输出格式,返回一个时间字符串

https://www.runoob.com/python/att-time-strftime.html

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com