Home All Groups Group Topic Archive Search About
Author
27 Jun 2005 9:35 AM
Li Pang
Hi,

In VB6 I used Now() -1 to get yesterday, but it's not allowed in vb.NET. Is
there a similar way to do it in vb.Net?

Thanks in advance

Author
27 Jun 2005 9:41 AM
Li Pang
May be work with
Now().AddDays(-1)

Show quoteHide quote
"Li Pang" wrote:

> Hi,
>
> In VB6 I used Now() -1 to get yesterday, but it's not allowed in vb.NET. Is
> there a similar way to do it in vb.Net?
>
> Thanks in advance
Author
27 Jun 2005 10:18 AM
Cor Ligthert
Li Pang,

You mean this?
Dim yesterday As DateTime = Now.AddDays(-1)

I hope this helps,

Cor
Author
27 Jun 2005 9:52 AM
Juan Pedro Gonzalez
Hi Li Pang,

You can use the following code:

Dim oTimeSpan As New System.TimeSpan(1,0,0,0)
Dim oDate As System.DateTime = System.DateTime.Now.Substract(oTimeSpan)

and oDate should contain yesterdays date...

Greetings,

Juan Pedro Gonzalez




Show quoteHide quote
"Li Pang" <LiP***@discussions.microsoft.com> escribió en el mensaje
news:96CB3185-0C56-47C6-8C95-0B1A3038E6B7@microsoft.com...
> Hi,
>
> In VB6 I used Now() -1 to get yesterday, but it's not allowed in vb.NET.
Is
> there a similar way to do it in vb.Net?
>
> Thanks in advance
Author
27 Jun 2005 10:26 AM
Larry Lard
Li Pang wrote:
> Hi,
>
> In VB6 I used Now() -1 to get yesterday, but it's not allowed in vb.NET. Is
> there a similar way to do it in vb.Net?
>
> Thanks in advance

As others have posted, Now.AddDays(-1) is the literal translation of
the VB6 expression Now() - 1.

But if you want *yesterday*, rather than *this time yesterday*, you
should be using Today, not Now.

--
Larry Lard
Replies to group please