使用今天日期和明天日期的查询获取日期 [英] Using query get date for today date and tomorrow date

查看:206
本文介绍了使用今天日期和明天日期的查询获取日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  Coursedetails选择 *  







 Courseid Coursename CourseType Coursedate Active 

1 REO Revalidation 2016- 08-28 00:00:00.000 A
2 RM Deck 2016-08-28 00:00:00.000 A
3 AFF Advance 2016-08-28 00:00:00.000 A
4 TFC油轮2016-08-28 00:00:00.000 A
5 CTF油轮2016-08-29 00:00:00.000 A
6 AMOS甲板2016-08-29 00:00:00.000 A
7 MFA Advance 2016-08-29 00:00:00.000 A
8 DFC油轮2016-08-29 00:00:00.000 A
9 ECDIS油轮2016-08-30 00:00 :00.000 A
10 GP甲板2016-08-30 00:0 0:00.000 A
11 DME Advance 2016-08-30 00:00:00.000 A
12 DFC油轮2016-08-30 00:00:00.000 A







当我运行上述查询时,从Coursedetails中选择*。以上输出我得到了。



我希望输出为课程日期仅限28日和29日。



  Coursedetails选择 *  







 Courseid Coursename CourseType Coursedate Active 

1 REO Revalidation 2016-08- 28 00:00:00.000 A
2 RM甲板2016-08-28 00:00:00.000 A
3 AFF Advance 2016-08-28 00:00:00.000 A
4 TFC油轮2016-08-28 00:00:00.000 A
5 CTF油轮2016-08-29 00:00:00.000 A
6 AMOS甲板2016-08-29 00:00:00.000 A
7 MFA Advance 2016-08-29 00:00:00.000 A
8 DFC油轮2016-08-29 00:00:00.000 A





获取查询我需要做什么更改我的选择语句查询



我是什么尝试过:



我希望输出为课程日期仅限第28和第29日期。

解决方案

查看 WHERE 子句:

SQL WHERE子句 [ ^ ]



看起来你需要认真学习SQL

SQL教程 [ ^ ]

<试试这个:



  SELECT < ListOfColumns> 
FROM TableName
WHERE DateField BETWEEN ' 2016-08-28' AND ' 2016-08-29'





  SELECT < ListOfColumns> 
FROM TableName
WHERE DateField IN ' 2016-08-28'' 2016-08-29'





  SELECT < ListOfColumns> 
FROM TableName
WHERE DateField> = ' 2016-08-28' AND DateField< = ' 2016-08-29'


Select * from  Coursedetails




Courseid    Coursename    CourseType        Coursedate             Active

   1         REO        Revalidation     2016-08-28 00:00:00.000     A
   2         RM         Deck             2016-08-28 00:00:00.000     A
   3         AFF        Advance          2016-08-28 00:00:00.000     A
   4         TFC        Tanker           2016-08-28 00:00:00.000     A
   5         CTF        Tanker           2016-08-29 00:00:00.000     A
   6         AMOS       Deck             2016-08-29 00:00:00.000     A
   7         MFA        Advance          2016-08-29 00:00:00.000     A
   8         DFC        Tanker           2016-08-29 00:00:00.000     A
   9         ECDIS      Tanker           2016-08-30 00:00:00.000     A
   10        GP         Deck             2016-08-30 00:00:00.000     A
   11        DME        Advance          2016-08-30 00:00:00.000     A
   12        DFC        Tanker           2016-08-30 00:00:00.000     A




When i run the above query Select * from Coursedetails. the above output i get.

I want the output as Course date 28th and 29th date only.

Select * from  Coursedetails




Courseid    Coursename    CourseType        Coursedate             Active

   1         REO        Revalidation     2016-08-28 00:00:00.000     A
   2         RM         Deck             2016-08-28 00:00:00.000     A
   3         AFF        Advance          2016-08-28 00:00:00.000     A
   4         TFC        Tanker           2016-08-28 00:00:00.000     A
   5         CTF        Tanker           2016-08-29 00:00:00.000     A
   6         AMOS       Deck             2016-08-29 00:00:00.000     A
   7         MFA        Advance          2016-08-29 00:00:00.000     A
   8         DFC        Tanker           2016-08-29 00:00:00.000     A



for getting query what changes i need to be my select statement Query

What I have tried:

I want the output as Course date 28th and 29th date only.

解决方案

Have a look at the WHERE clause:
SQL WHERE Clause[^]

Looks like you need to learn SQL seriously
SQL Tutorial[^]


Try this:

SELECT <ListOfColumns>
FROM TableName
WHERE DateField BETWEEN '2016-08-28' AND '2016-08-29'


or

SELECT <ListOfColumns>
FROM TableName
WHERE DateField IN ('2016-08-28', '2016-08-29')


or

SELECT <ListOfColumns>
FROM TableName
WHERE DateField >= '2016-08-28' AND DateField <='2016-08-29'


这篇关于使用今天日期和明天日期的查询获取日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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