在 VB.NET 中获取日期差异 [英] Get date difference in VB.NET

查看:29
本文介绍了在 VB.NET 中获取日期差异的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想获得两个日期时间选择器在年、月和月中选择的两个日期之间的差异天在单独的文本框中.

I want to get the difference between two dates chosen by two date time pickers in years, months & days in separate text boxes.

我试过了:

txtyrs.text = datediff(datetimepicker1,datetimepicker2)

它不起作用.

推荐答案

必须先做一些计算,然后,

Some calculations must be done and then,

dim ts as TimeSpan = dtpicker1.value - dtpicker.value
dim days, months, years as integer
months = 12*(dtp1.value.year - dtp2.value.year) (dtp1.value.month-dtp2.value.month)

... 更多

这篇关于在 VB.NET 中获取日期差异的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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