在SQL中获取周数的日期 [英] Getting week number of date in SQL
问题描述
有没有办法获取与数据库无关的日期的周数?例如要获取我使用的日期的月份: / p>
SELECT EXTRACT(MONTH FROM:DATE)
但EXTRACT函数在SQL92中不知道几周。
请注意,我想要一个数据库独立的解决方案!不要误解为MS SQL Server的问题。
似乎没有一个标准的SQL函数从日期提取周数 - 请参阅此处比较不同SQL方言可以从日期字段中提取不同的日期类型。
Is there a way to get the week number of a date with SQL that is database independent?
For example to get the month of a date I use:
SELECT EXTRACT(MONTH FROM :DATE)
But the EXTRACT function doesn't know about weeks in SQL92.
Please pay attention to the fact that I want a solution that is database independent! Do not misinterpret this as a question regarding MS SQL Server.
There doesn't appear to be a single standard SQL function to extract the week number from a date - see here for a comparison of how different SQL dialects can extract different dateparts from date fields.
这篇关于在SQL中获取周数的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!