473,472 Members | 2,247 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Get yesterday date

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
Nov 21 '05 #1
4 57642
May be work with
Now().AddDays(-1)

"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

Nov 21 '05 #2
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


"Li Pang" <Li****@discussions.microsoft.com> escribió en el mensaje
news:96**********************************@microsof t.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

Nov 21 '05 #3
Li Pang,

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

I hope this helps,

Cor
Nov 21 '05 #4


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

Nov 21 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: necromancer_stupidspambot | last post by:
Hi, I am trying to find a simple way to get "yesterday's" date. I know I can build various check to seee if we are in leap year, if we are the 1st then yesterday is the 31(or 30 depending of...
3
by: Darren | last post by:
Hello, How would I write in SQL or ASP the following?: Count number of Database Records between NOW and 24 HOURS EARLIER? I know how to retrieve recordsets etc - its just the date thing I cant...
4
by: Manny Chohan | last post by:
Hi Can anyone tell me how i can calculate yesterday date using asp? Thanks manny
15
by: Paul J. Ettl | last post by:
Two questions: I use var date1 = new Date(); to get todays date. But how can I get yesterdays date? Furthermore I use
8
by: Anonmyous | last post by:
Hello, how can I get the yesterdays date? Thanks for any suggestions and tips.
1
by: Joris De Groote | last post by:
Hi How can I easily make a date object that has the date in it of yesterday? (yesterdag of the date the program runs ;) ). Thanks
10
by: WebCM | last post by:
There is a function: http://paste.ubuntu.com/21865 It needs GMT date in YYYY-MM-DD HH:MM:SS format - in SQL: datetime. If date is the same as today, the function returns "Today". There is one...
18
Jerry Maiapu
by: Jerry Maiapu | last post by:
I am trying to create a simple clock in clock out (timesheet) in ms access. I have two tables (tblnames for staff names and tbldates for clocking times). tblnames has 2 fields namely...
6
by: ziycon | last post by:
I have a script that outputs 'Today' or 'Yesterday' for the date a piece of content was posted but if its the first of the month yesterday don't work. Is there a way to subtract one day from the...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.