Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共6 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:[求助]时间计算

1楼
想学狐表 发表于:2011/5/14 12:48:00


图片点击可在新窗口打开查看此主题相关图片如下:未命名.jpg
图片点击可在新窗口打开查看

1、手术间隔等于  避孕情况开始日期  减  最小子女出生日期     想得的结果是多少天,表达式怎么写?

2、男扎停药时间,指男扎后要用半个月(6个月)的药后停药,以就是避孕开始日期加6个月后的时间,想得的结果为时间,表达式怎么写?


 

2楼
hhbb 发表于:2011/5/14 13:06:00

Dim d1 as Date = #3/17/2002 12:30#
Dim
d2 as Date = #1/1/2008 18:30#
Dim t As TimeSpan = d2 - d1

Output.Show(t.TotalDays &
"")

 

AddMonths

给日期值加上指定的月数。

语法:

AddMonths(Value)

Value: 要加上的月数,可以是负数也可以是正数。

例如:

Dim d As Date = #2/28/2008#
Dim
d1 As Date = d.
AddMonths(10) '加上10个月
Dim
d2
As Date = d.AddMonths(-10) '减去10个月
Output.Show(
"10个月后的日期:" & d1)
Output.Show(
"10个月前的日期:"
& d2)

3楼
程兴刚 发表于:2011/5/14 13:07:00

参考:时段概述章节:

 

 

Dim t0 As New TimeSpan(10,0,5)
Dim
t1 As New TimeSpan(40,6,30,15)
Dim
t2 As New TimeSpan(40,20,45)
Dim
t3 As TimeSpan
t3
= t1.Subtract(t2) 't3等于t1减去t2
t3 = t3.Add(t0)
't3加上t0
Output.Show(t3.Days &
"天" & t3.Hours & "小时" & t3.Minutes & "分" & t3.Seconds & "秒")

在命令窗口执行上述代码,得到的输出结果是:39天0小时9分35秒

4楼
想学狐表 发表于:2011/5/14 14:21:00
我怎么搞不定,在手术间隔里,,,,男扎停药时间里,具体怎么写,请高手给我写出来,谢谢!!
5楼
hhbb 发表于:2011/5/14 15:09:00

DataColChanged事件:

 

If e.DataRow.IsNull("避孕情况开始日期") = False AndAlso  e.DataRow.IsNull("避孕情况开始日期") = False  Then
    e.DataRow("手术间隔") = ( e.DataRow("避孕情况开始日期")- e.DataRow("最小子女出生日期")).TotalDays
    If e.DataRow("避孕情况") = "男扎" Then
        e.DataRow("男扎停药时间") =  e.DataRow("避孕情况开始日期").AddMonths(6)
    End If
End If

共6 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .03125 s, 2 queries.