Home All Groups Group Topic Archive Search About
Author
11 Mar 2006 2:24 PM
Dennis D.
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?

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/

Author
11 Mar 2006 3:49 PM
Armin Zingler
"Dennis D." <no***@nowhere.com> schrieb
> 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?

    ts = new timespan(n, 0, 0, 0)

- or -

    ts= timespan.fromdays(n)


> If I subtract 4 days from the 2nd day of the month using integers I
> get a -1 (no date) for a result.

Code?

> 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

    dim dt1, dt2 as datetime

    dt1 = #3/25/2006#
    dt2 = dt1.adddays(-4)

- or -

    dim ts as new timespan(4, 0, 0, 0)

    dt2 = dt1.subtract(ts)


Armin
Author
12 Mar 2006 12:50 AM
Homer J Simpson
"Dennis D." <no***@nowhere.com> wrote in message
news:u4II2dRRGHA.5908@TK2MSFTNGP14.phx.gbl...
> Hello:
> I want to subtract a timespan from the selectionrange.start of a month
> calendar.

Like

Dim today As System.DateTime
Dim answer As System.DateTime
today = System.DateTime.Now
answer = today.AddDays(-36)

??