获取具有更高日期的行,而不是特定于MM/DD/YYYY格式的行。

时间:2022-02-15 17:14:34

sorry for asking a really amateurish question, but I am only beginning to learn oracle.

很抱歉问了一个非常业余的问题,但我才刚刚开始学习oracle。

I need to extract rows based on a date column which is in MM/DD/YYYY format , but I can't formulate a proper query. I used to_date function too but no fun.

我需要基于MM/DD/YYYY格式的日期列提取行,但是我不能制定一个合适的查询。我也用了to_date函数,但一点都不好玩。

I need to extract rows from XTABLE where XDATE is higher than 10/21/2011 (MM/DD/YYYY)

我需要从XDATE大于10/21/2011的XTABLE中提取行(MM/DD/YYYY)

select * from XTABLE where XDATE >= '10/21/2011'

doesn't work, neither does

不工作,也没有

select * from XTABLE where to_date(XDATE,'MM/DD/YYYY') > to_date('28/10/2011','MM/DD/YYYY')

1 个解决方案

#1


3  

Columns of type DATE aren't stored in MM/DD/YYYY format: It's just presentation according to your current NLS settings.

类型日期的列不存储在MM/DD/YYYY格式中:它只是根据您当前的NLS设置进行表示。

Your query should be:

您的查询应该是:

select * from XTABLE where XDATE >= date '2011-10-21'

See http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements003.htm#BABGIGCJ for information on date and other 'datetime' literals.

请参见http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements003.htm,以获取日期和其他“datetime”文本的信息。

#1


3  

Columns of type DATE aren't stored in MM/DD/YYYY format: It's just presentation according to your current NLS settings.

类型日期的列不存储在MM/DD/YYYY格式中:它只是根据您当前的NLS设置进行表示。

Your query should be:

您的查询应该是:

select * from XTABLE where XDATE >= date '2011-10-21'

See http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements003.htm#BABGIGCJ for information on date and other 'datetime' literals.

请参见http://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements003.htm,以获取日期和其他“datetime”文本的信息。