|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Date functionI am trying to find out any function or code to calculate days between to
dates, and another one that I select a date and then select a number of days, weeks, or years from a control, and I will bring me what they It would be after the number of days or weeks selected. Lets say for example I would like to know what date it would be after 20 days from todays date. Thanks for any suggestions . Eduardo78,
You could use Visual Basic's DateDiff and DateAdd functions. Kerry Moorman Show quoteHide quote "Eduardo78" wrote: > I am trying to find out any function or code to calculate days between to > dates, and another one that I select a date and then select a number of days, > weeks, or years from a control, and I will bring me what they It would be > after the number of days or weeks selected. > > Lets say for example I would like to know what date it would be after 20 > days from todays date. > > Thanks for any suggestions . Have a look at the System.TimeSpan class. A TimeSpan is the difference
between two dates - you can determine how many years, days, hours, minutes, seconds, etc exist between two dates. http://msdn.microsoft.com/library/en-us/cpref/html/frlrfsystemtimespanclasstopic.asp Regards, -Adam. Eduardo78 wrote: Show quoteHide quote > I am trying to find out any function or code to calculate days between to > dates, and another one that I select a date and then select a number of days, > weeks, or years from a control, and I will bring me what they It would be > after the number of days or weeks selected. > > Lets say for example I would like to know what date it would be after 20 > days from todays date. > > Thanks for any suggestions . Eduardo,
Just add 20 days to your date mydate = mydate.adddays(20) http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemdatetimeclassadddaystopic.asp There are more things you can do direct with datetime, however not direct with the structure or "structures" in that structure. By instance using the datetime.ticks gives you endless posibilities. I hope this helps, Cor |
|||||||||||||||||||||||