在Oracle中将日期类型转换为mm/dd/yyyy格式 [英] convert date type to mm/dd/yyyy format in oracle
问题描述
我有一个将Start_date和End_Date作为输入参数的过程.这些参数是Date数据类型.我的查询如下:
从表名称中选择count(1),其中检查日期在开始日期和结束日期之间;
当我提供值时,输入参数为:start_date:1/1/1800或1/1/2000,查询将开始日期设为1-jan-00,结果我没有得到正确的结果.
我还尝试使用to_date(to_char(start_date,''mm/dd/yyyyy),''mm/dd/yyyy'')将其转换为mm/dd/yyyy格式并存储在timestamp(6)类型的变量中但仍然无法给出正确的结果.
请让我知道如何执行此操作.
I have a procedure which takes Start_date and End_Date as input parameters. These parameters are of Date datatype.My query is as follows:
select count(1) from table_name where inspection_date between start_date and end_date;
when I provide values the input parameters as: start_date: 1/1/1800 or 1/1/2000 the query take the start date as 1-jan-00 as result of which I am not getting correct result.
I also tried to convert it into mm/dd/yyyy format using to_date(to_char(start_date,''mm/dd/yyyy),''mm/dd/yyyy'') and stored in a variable of type timestamp(6) but still its not giving correct result .
Please let me know how to perform this operation.
推荐答案
select count(1)
from table_name
where inspection_date
between
to_date(start_date, 'MM/DD/YYYY'))
and to_date(end_date, 'MM/DD/YYYY'));
并确保将start_date和end_date输入为:
And make sure you inout the start_date and end_date as :
<br />
''11/01/2008''<br />
''11/01/2010''<br />
谢谢,
Kuthuparakkal
Thanks,
Kuthuparakkal
这篇关于在Oracle中将日期类型转换为mm/dd/yyyy格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!