加入日期和时间为DateTime在C# [英] Join Date and Time to DateTime in C#
本文介绍了加入日期和时间为DateTime在C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我从检索与iSeries那里是一个单独的日期和时间字段的数据。我想它们连接成一个DateTime场在我的C#项目。我没有看到一个方法来每次只添加到DateTime字段。你会如何建议完成这个?
I am retrieving data from an iSeries where there is a separate date and time fields. I want to join them into a DateTime field in my C# project. I don't see a way to add just a time to a DateTime field. How would you suggest accomplishing this?
推荐答案
他们是如何存储?假设日期部分被存储为的DateTime
当日有问题的午夜,时间是时间跨度
,你可以将它们添加
How are they being stored? Assuming that the date portion is being stored as a DateTime
of midnight of the day in question and the time is a TimeSpan
, you can just add them.
DateTime date = ...;
TimeSpan time = ...;
DateTime result = date + time;
这篇关于加入日期和时间为DateTime在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文