17,086
社区成员
发帖
与我相关
我的任务
分享
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date dBefore = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.add(Calendar.DAY_OF_MONTH,-30);
dBefore = calendar.getTime();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date dBefore = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.add(Calendar.DAY_OF_MONTH, -30);
dBefore = calendar.getTime();
System.out.print("测试"+dBefore);
String sql = "select MOB_NUMBER from em_adc_reverse_order_info where created_date > to_date('"
+ sdf.format(dBefore)
+ "','yyyy-mm-dd hh24:mi:ss')"
查询语句里面咋处理一个月?正处于学习阶段,能帮忙答惑下吗?谢谢 [/quote]
先做个测试,为啥 [quote=引用 3 楼 qq_30003009 的回复:] [quote=引用 1 楼 ghx287524027 的回复:] 不是oracle的吧,另外对于有31天的月,(- 30)是有漏洞的吧这样一天的可以一个月的不行calendar.add(Calendar.DAY_OF_MONTH, -1);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date dBefore = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.add(Calendar.DAY_OF_MONTH, -30);
dBefore = calendar.getTime();
System.out.print("测试"+dBefore);
String sql = "select MOB_NUMBER from em_adc_reverse_order_info where created_date > to_date('"
+ sdf.format(dBefore)
+ "','yyyy-mm-dd hh24:mi:ss')"
查询语句里面咋处理一个月?正处于学习阶段,能帮忙答惑下吗?谢谢 [/quote]
查看oracle 中 to_date() 函数的用法:
to_date('2004-05-07 13:23:44','yyyy-mm-dd hh24:mi:ss')
to_date('2004-05-07','yyyy-mm-dd')
to_date('2004-05','yyyy-mm')
to_date('2004','yyyy')
两个参数在格式上是有关系的先做个测试,为啥 [quote=引用 1 楼 ghx287524027 的回复:] 不是oracle的吧,另外对于有31天的月,(- 30)是有漏洞的吧这样一天的可以一个月的不行calendar.add(Calendar.DAY_OF_MONTH, -1);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date dBefore = new Date();
Calendar calendar = Calendar.getInstance();
calendar.setTime(new Date());
calendar.add(Calendar.DAY_OF_MONTH, -30);
dBefore = calendar.getTime();
System.out.print("测试"+dBefore);
String sql = "select MOB_NUMBER from em_adc_reverse_order_info where created_date > to_date('"
+ sdf.format(dBefore)
+ "','yyyy-mm-dd hh24:mi:ss')"
查询语句里面咋处理一个月?正处于学习阶段,能帮忙答惑下吗?谢谢 先做个测试,为啥 不是oracle的吧,另外对于有31天的月,(- 30)是有漏洞的吧这样一天的可以一个月的不行calendar.add(Calendar.DAY_OF_MONTH, -1);
不是oracle的吧,另外对于有31天的月,(- 30)是有漏洞的吧
calendar.add(Calendar.DAY_OF_MONTH, -1);
这样一天的可以一个月的不行