|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Coding a TimeSpanI want to subtract a timespan from the selectionrange.start of a month calendar. The selectionrange.start of a month calendar is a date, and it is possible to subtract a timespan from a date and get a date, from which I will extract the day. How do I assign an integer to represent an 'n' day timespan, especially without using ticks? If I subtract 4 days from the 2nd day of the month using integers I get a -1 (no date) for a result. The result should be 29, the 29th day of the previous month. So far, the timespan error indicates the parts of the timespan are read only, and I haven't been able to negotiate a constructor to make the timespan day = some integer variable, and I haven't found any code examples assigning a value to a timespan. More or less: Thursday = 4 selectionrange.start - Thursday Same as 3/25/06 - 4 days = 3/21/06 Thank You, Dennis. http://www.dennisys.com/ "Dennis D." <no***@nowhere.com> schrieb ts = new timespan(n, 0, 0, 0)> Hello: > I want to subtract a timespan from the selectionrange.start of a > month calendar. > > The selectionrange.start of a month calendar is a date, and it is > possible to subtract a timespan from a date and get a date, from > which I will extract the day. > > How do I assign an integer to represent an 'n' day timespan, > especially without using ticks? - or - ts= timespan.fromdays(n) > If I subtract 4 days from the 2nd day of the month using integers I Code?> get a -1 (no date) for a result. > The result should be 29, the 29th day of the previous month. dim dt1, dt2 as datetime > > So far, the timespan error indicates the parts of the timespan are > read only, and I haven't been able to negotiate a constructor to > make the timespan day = some integer variable, and I haven't found > any code examples assigning a value to a timespan. > > More or less: > Thursday = 4 > selectionrange.start - Thursday > Same as 3/25/06 - 4 days = 3/21/06 dt1 = #3/25/2006# dt2 = dt1.adddays(-4) - or - dim ts as new timespan(4, 0, 0, 0) dt2 = dt1.subtract(ts) Armin "Dennis D." <no***@nowhere.com> wrote in message Likenews:u4II2dRRGHA.5908@TK2MSFTNGP14.phx.gbl... > Hello: > I want to subtract a timespan from the selectionrange.start of a month > calendar. Dim today As System.DateTime Dim answer As System.DateTime today = System.DateTime.Now answer = today.AddDays(-36) ??
[VB.NET] How to store/load XML schema internally...
Passing values bewteen user controls is separate web forms Best way to implement 2 controls on one window Best value Help file builder Write to an existing ASCII file Newbee ASP.NET Questions Can't Change Installation Drive for new install of Visual Studio Professional 2005 How to programmatically change directory attributes VB.NET 2.0 Simple data grid question |
|||||||||||||||||||||||