返回带有日期字段的N行 [英] Returning N rows with a datefield

查看:72
本文介绍了返回带有日期字段的N行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试从表中返回行,在我有create_date字段的地方将其称为A.在表中,我在该字段中有数据(21年3月21日),但是当我对其进行排序时,它不起作用.如何获取日期字段以返回具有特定日期的行?我已经尝试过Trunc功能,但无法正常工作.任何帮助将不胜感激.

>从ods_own.A
中选择a.item_oid 其中trunc(a.create_date)= to_date('20110321','YYYYMMDD')

I am trying to return rows from a table, call it A where i have a create_date field. In the talble i have data (21-MAR-11) in that field but when i sort on it it does not work. How can i get the date field to return rows with a certain date? i have tried Trunc fucntion but its not working. Any help would be appreciated.

>select a.item_oid from ods_own.A
Where trunc(a.create_date) = to_date(‘20110321’,’YYYYMMDD’)

推荐答案

我想您需要将其转换为datetime

其中Convert(DateTime,a.create_date)= Convert(DateTime,to_date)
i guess you need to convert this to datetime

Where Convert(DateTime,a.create_date) = Convert(DateTime,to_date)


这篇关于返回带有日期字段的N行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆