Foxtable(狐表)用户栏目专家坐堂 → 关于工时计算


  共有2511人关注过本帖树形打印复制链接

主题:关于工时计算

帅哥哟,离线,有人找我吗?
有点色
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/6/13 19:16:00 [显示全部帖子]

 Dim d1 As Date = "2017-06-12 8:00:00"
Dim d2 As Date = "2017-06-13 17:30:00"
Dim day As Integer = (d2-d1).Totaldays
msgbox(day)
Dim hour As Integer = (new Date(1,1,1,d2.hour, d2.Minute, d2.Second) - new Date(1,1,1, d1.hour, d1.minute, d1.second)).Totalhours
msgbox(hour)
day = day + iif(hour<=4, 0.5, 1)
msgbox(day)
[此贴子已经被作者于2017/6/14 9:34:55编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
有点色
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/6/14 9:36:00 [显示全部帖子]

Dim d1 As Date = "2017-06-12 8:00:00"
Dim d2 As Date = "2017-06-13 12:00:00"
Dim day As Integer = (d2-d1).Totaldays
msgbox(day)
Dim hour As Integer = (new Date(1,1,1,d2.hour, d2.Minute, d2.Second) - new Date(1,1,1, d1.hour, d1.minute, d1.second)).Totalhours
msgbox(hour)
Dim days = day + iif(hour<=4, 0.5, 1)
msgbox(days)

 回到顶部
帅哥哟,离线,有人找我吗?
有点色
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/6/14 10:37:00 [显示全部帖子]

分开统计

 

'Dim d1 As Date = "2017-06-12 8:00:00"
'Dim d2 As Date = "2017-06-13 12:00:00"
'Dim d1 As Date = "2017-06-12 13:30:00"
'Dim d2 As Date = "2017-06-13 18:00:00"
Dim d1 As Date = "2017-06-12 21:00:00"
Dim d2 As Date = "2017-06-14 12:00:00"
If d1.Hour = 8 Then '上午
    Dim day As Integer = Math.Floor((d2-d1).Totaldays)
    Dim hour As Integer = (new Date(1,1,1,d2.hour, d2.Minute, d2.Second) - new Date(1,1,1, d1.hour, d1.minute, d1.second)).Totalhours
    Dim days = day + iif(hour<=4, 0.5, 1)
    msgbox(days)
ElseIf d1.hour = 13 Then '下午
    Dim day As Integer = Math.Floor((d2-d1).Totaldays)
    Dim hour As Integer = (new Date(1,1,1,d2.hour, d2.Minute, d2.Second) - new Date(1,1,1, d1.hour, d1.minute, d1.second)).Totalhours
    Dim days = day + iif(hour<=4, 0.5, 1)
    msgbox(days)   
ElseIf d1.hour = 21 Then '晚上
    Dim day As Integer = Math.Floor((d2-d1).Totaldays)
    Dim hour As Integer = (new Date(1,1,1,d2.hour, d2.Minute, d2.Second) - new Date(1,1,1, d1.hour, d1.minute, d1.second)).Totalhours
    Dim days = day + iif(-hour>=13, 1, iif(-hour>=9, 1.5, 2))
    msgbox(days)      
End If


 回到顶部
帅哥哟,离线,有人找我吗?
有点色
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:13837 积分:69650 威望:0 精华:0 注册:2016/11/1 14:42:00
  发帖心情 Post By:2017/6/19 10:47:00 [显示全部帖子]

Dim d1 As Date = "2017-06-13"
Dim n As Double = 1.5
Dim d2 As Date = d1.AddDays(math.Floor(n-1))
If n - math.Floor(n) = 0.5 Then
    d2 = d2.AddHours(12)
Else
    d2 = d2.AddHours(-6)
End If
msgbox(d2)

 回到顶部