从以下部分日起建立日期时间的问题。一个月,一年 [英] problem building datetime from the following parts day. month ,year

查看:74
本文介绍了从以下部分日起建立日期时间的问题。一个月,一年的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

通过将以下内容放在一起来创建一个新的日期



周围有问题



Generating a fresh date by putting the following together

Have problem around

int mday   = Convert.ToInt32(txt_Date_Of_Loan.Text.day);

where txt_Date_Of_Loan.Text is a datetime  and we are extracting the  day

from
                 int myear  = Convert.ToInt32(txt_Start_Year.Text);
                 int mmonth = Convert.ToInt32(txt_Start_Month.Text);
                 int mday   = Convert.ToInt32(txt_Date_Off.Text.day);

                 DateTime mdate = new DateTime(myear,mmonth,mday);


Please assist by correcting the day extraction from (txt_Date_Of_Loan.Text)

Thanks

推荐答案

查看 DateTime.Parse [ ^ ]



Look at the MSDN documentation for DateTime.Parse[^]

var dateOfLoan = DateTime.Parse(txt_Date_Of_Loan.Text);

var loanDay = dateOfLoan.Day;





如果你进一步了解日期时间 [ ^ ]结构,您可以使用日等属性 [ ^ ],年等,以检索您要查找的详细信息。



And if you look further on the DateTime [^]structure, you could use properties such as Day[^], Year etc. to retrieve the details you are looking for.


这篇关于从以下部分日起建立日期时间的问题。一个月,一年的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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