如何以23:59:59格式获得约会时间 [英] How to get time for a date in 23:59:59 format

查看:93
本文介绍了如何以23:59:59格式获得约会时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个列日期,其中的值包含日期及其相应的时间戳

但是我查询表的查询之间有两个日期值



例如2014-06-24 00:00:00和2014-06-26 00:00:00



所以该查询仅检索24,25的结果,但不检索26的结果,因为时间是午夜。

那么有没有办法将date2中的00:00:00转换为23:59:59使用C#

I have a column date which has the values with date and its coressponding time stamp
but the query with which I am querying the table has a between which has 2 date values

eg 2014-06-24 00:00:00 and 2014-06-26 00:00:00

So the query retrieves the result only for 24,25 but not for 26 as the time is for midnight.
So is there any way to convert 00:00:00 in date2 to 23:59:59 using C#

推荐答案

参考: convert-datetime-time-from-000000-to 235959 [ ^ ]


假设您有两个日期时间作为搜索方法的参数,例如startdt,enddt

您可以做的是,通过添加一天如下设置结束日期

assume you have two date times as parameters to your search method, for example startdt, enddt
what you can do is, set end date by adding one day like below
enddt = enddt.AddDays(1);



现在用startdt调用你的函数,enddt


now call your function with startdt, enddt


前段时间我回答了类似的问题。简单的方法是忘记时间部分,只使用日期部分。也许我的解决方案会帮助你:



如何在c#中查询窗口形式之间的日期 [ ^ ]
Some time ago I've answered similar question. Simples way is to forget about Time part and use only date part. Maybe my solution will help you:

how to query for date in between for window forms in c#[^]


这篇关于如何以23:59:59格式获得约会时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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