具体日期和时间计算 [英] Specific Date and Time calculation

查看:93
本文介绍了具体日期和时间计算的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果工作周是星期一到星期五,时间范围是早上6点到晚上10点,周六时间段是上午8点到下午6点,我试图计算一个问题所花费的时间。没有星期天。以下是这种情况:我在周一早上9:45打开一张票,但是直到周三下午2:50才关闭它。这三天我只能包括上午6点到晚上10点的时间范围。寻找37 HR和05分钟的答案。有没有一种简单的方法可以做到这一点?


其他信息,我正在运行访问2010年,我对SQL的了解最多也是有限的。我当前的数据库具有一般格式的开始和结束日期以包括时间。我已经有一个事件功能,可以消除我周围需要调整周末的周末。当我被告知需要包含这个计算时,我的数据库已经完成。

解决方案

嗯,这很好。只是这个小额外的功能'会炸掉你的大脑来解决它。可爱。


这可以用SQL做,但我不会打扰。它会比在VBA中做起来更复杂,而且不会很有趣。


工作的基础是你有一个开始时间和结束时间。首先计算两者之间的整周数。接下来整整几天,当你了解它时,确定每个星期的哪一天。接下来确定在开始日期结束前剩余的小时数,然后确定结束日到结束时间的小时数。


非常有趣。添加所有贡献值以产生所需的值。


这是我对它的看法:

展开 | < span class =codeLinkonclick =selectAll(this);>选择 | Wrap | 行号


使用带有start& amp;表的jforbes的完全不同的方法结束时间。




代码不是太可怕

展开 | 选择 | Wrap | 行号

I am trying to calculate the amount of time spent on an issue if the work week is Monday thru Friday with a time frame of 6 AM to 10 PM only and Saturdays with a time frame of 8 AM to 6 PM. No Sundays. Following is the scenario: I open a ticket on Monday morning at 9:45 AM but do not close it out until Wednesday at 2:50 PM. I can only include the time frame of 6 am to 10 pm for all three days. Looking for an answer of 37 HRs and 05 minutes. Is there an easy way to do this?

Additional info, I am running access 2010 and my knowledge of SQL is limited at best. My current DB has a start and end date in a general format to include the time. I already have an event function that eliminates the weekends which I need to adjust now for Saturdays being included. My db was completed when I was told I needed to include this calculation.

解决方案

Well, that''s nice. Just this small additional feature that''ll fry your brain working it out. Lovely.

It''s possible to do in SQL but I wouldn''t bother. It would be even more complex than doing it in VBA, and that won''t be fun.

Work on the basis that you have a start time and and end time. Start by calculating how many whole weeks fall between the two. Next how many whole days and, while you''re about it, determine what day of the week each is. Next determine how many hours left till the end of the start day, then how many hours of the end day till the end time.

All great fun. Add up all the contributing values to produce the value required.


This is my take on it:

Expand|Select|Wrap|Line Numbers


Totally different approach to jforbes using a table with start & end time.



Code isn''t too horrendous

Expand|Select|Wrap|Line Numbers


这篇关于具体日期和时间计算的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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