根据当前时间以12小时格式选择一天中的所有时间 [英] Select all times in a day in 12 hrs format based on current time

查看:119
本文介绍了根据当前时间以12小时格式选择一天中的所有时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我需要根据当前时间以12小时格式选择所有小时。如果是03:00 PM我应该在03:00 PM之间获得所有时间非常感谢。非常感谢。谢谢。



我的尝试:



Hi All,
I need to select all hrs in day in 12 hrs format based on current time .ie if it is 03:00 PM I should get all the times between 03:00 PM and 12:00 AM .Any help will be really appreciated .Thanks in Advance

What I have tried:

select distinct CONVERT(varchar(15),CAST( dateadd(hour,number-1,'01-jan-2017' ) AS TIME),100) as slots from master..spt_values where number>=1 and number<=24

推荐答案

您的意思是要返回所有行输入日期是从现在到今晚的午夜?如果是这样,请尝试以下方法:

Do you mean you want to return all rows where the enter date is between now and midnight tonight? If so, try something like:
SELECT * FROM MyTable WHERE EnterDateColumn BETWEEN @StartDate AND CONVERT(DATE, DATEADD(dd, 1, @StartDate))



如果你不这样做,你需要准确解释你的意思,可能还有输入和输出的例子......


If you don't then you need to explain exactly what you do mean, probably with input and output examples...


这篇关于根据当前时间以12小时格式选择一天中的所有时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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