本文介绍了在两次之间检索数据(从到到)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当iam试图从"todate"中获取最新数据时,则无法获取

它在显示日期之前显示日期

假设我选择jan10 th

它显示直到1月9日的数据


我们需要在SQL中使用什么数据类型datetime或smalldatetime

when iam trying to retrive from to todate the data present in ''todate'' is not retrieving

it displaying date before todate is displaying

suppose i select jan10 th

it displays data till jan 9th


what datatype we need to use in sql either datetime or smalldatetime

推荐答案

SELECT * FROM myTable WHERE myDate BETWEEN '2011-01-10' AND GETDATE()

,它将选择2011年1月10日至今天之间的所有日期.如果需要排除日期,则需要对WHERE子句进行不同的编码:

This selects all dates between 10th Jan 2011 and today inclusive. If you need to exclude a date, you will need to code the WHERE clause differently:

SELECT * FROM myTable WHERE myDate > '2011-01-10' AND myDate <= GETDATE()


这篇关于在两次之间检索数据(从到到)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-02 15:36