Home All Groups Group Topic Archive Search About

Help with date.addHours()

Author
7 Aug 2006 10:08 PM
VR
Hi all, I'm sure I'm missing something while dealing with dates in my
code.... If anybody could give me a clue...

Here's the code:

dim dt1,dt2 as dateTime
dt1 = new dateTime(2006,1,1,22,0,0)
dt2 = dt1.addHours(3)

the problem is that I get always the same date in dt1 and dt2.

If I change the code to

dim dt1,dt2 as dateTime
dt1 = new dateTime(2006,1,1,22,0,0)
dt2 = dt1
dt2 = dt2.addHours(3)

I get the same results...


Shouldn't dt2 get the value of 1/2/2006 01:00?

Thanks a lot,
Regards,
Victor

Author
8 Aug 2006 5:43 AM
Morten Wennevik
Hi Victor,

I can't reproduce your error.  Are you sure you are reading the result  =

correctly?

On Tue, 08 Aug 2006 00:08:00 +0200, VR <vc***@hotmail.com> wrote:

> Hi all, I'm sure I'm missing something while dealing with dates in my
> code.... If anybody could give me a clue...
>
> Here's the code:
>
> dim dt1,dt2 as dateTime
> dt1 =3D new dateTime(2006,1,1,22,0,0)
> dt2 =3D dt1.addHours(3)
>

I get
dt1 =3D 01.01.2006 22:00:00
dt2 =3D 02.01.2006 01:00:00

> the problem is that I get always the same date in dt1 and dt2.
>
> If I change the code to
>
> dim dt1,dt2 as dateTime
> dt1 =3D new dateTime(2006,1,1,22,0,0)
> dt2 =3D dt1
> dt2 =3D dt2.addHours(3)
>
> I get the same results...

I get
dt1 =3D 01.01.2006 22:00:00
dt2 =3D 02.01.2006 01:00:00
>
>
> Shouldn't dt2 get the value of 1/2/2006 01:00?

You should, and I'm pretty sure you do too


-- =

Happy Coding!
Morten Wennevik [C# MVP]
Author
13 Aug 2006 6:35 PM
VR
Sorry, I almost forgot the post....

Well, I really got surprised when I reboot my machine and everything went
fine again.

I should not say it is a framework or windows problem, I think the problem
is that I have a celeron 766 + 256MB running MSDE + VS.Net, building and
rebuilding the solution for 3 days without stopping or rebooting the
machine.... I think my machine just do not handle this kind of load....


sorry again...

Victor




"Morten Wennevik" <MortenWenne***@hotmail.com> wrote in message
news:op.tdx96z1xklbvpo@tr024.bouvet.no...
Hi Victor,

I can't reproduce your error.  Are you sure you are reading the result
correctly?

On Tue, 08 Aug 2006 00:08:00 +0200, VR <vc***@hotmail.com> wrote:

> Hi all, I'm sure I'm missing something while dealing with dates in my
> code.... If anybody could give me a clue...
>
> Here's the code:
>
> dim dt1,dt2 as dateTime
> dt1 = new dateTime(2006,1,1,22,0,0)
> dt2 = dt1.addHours(3)
>

I get
dt1 = 01.01.2006 22:00:00
dt2 = 02.01.2006 01:00:00

> the problem is that I get always the same date in dt1 and dt2.
>
> If I change the code to
>
> dim dt1,dt2 as dateTime
> dt1 = new dateTime(2006,1,1,22,0,0)
> dt2 = dt1
> dt2 = dt2.addHours(3)
>
> I get the same results...

I get
dt1 = 01.01.2006 22:00:00
dt2 = 02.01.2006 01:00:00
>
>
> Shouldn't dt2 get the value of 1/2/2006 01:00?

You should, and I'm pretty sure you do too


--
Happy Coding!
Morten Wennevik [C# MVP]

AddThis Social Bookmark Button