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 4 57912
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
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****@discuss ions.microsoft. com> escribió en el mensaje
news:96******** *************** ***********@mic rosoft.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
Li Pang,
You mean this?
Dim yesterday As DateTime = Now.AddDays(-1)
I hope this helps,
Cor
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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
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 the month) etc. but there is got to
be a simpler way than that. I was thinking of using the gmtime (field 7 as
you can see int the code)then substract one, then use strptime to rebuild
the time but it doesn't work(probably because I misunderstood...
|
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 grasp. I am
stuck getting the 24 hours earlier data capture.
Thanks!
Gary.
|
by: Manny Chohan |
last post by:
Hi Can anyone tell me how i can calculate yesterday date using asp?
Thanks
manny
|
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
|
by: Anonmyous |
last post by:
Hello,
how can I get the yesterdays date?
Thanks for any suggestions and tips.
| |
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
|
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 problem. This function does not recognize time zones.
How to adjust date to user's time zone? Is converting to timestamp()
and then to format readable to visitors the one and only solution
(e.g. strtotime() + date() OR DateTime object)? Perhaps,...
|
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 id=autonumber,names =text. and tbldates has 4 fiels Id=autonumber,namesid=number, clockin=time/date and clock out =date/time.
the twos have a one to many relationship
I have a form that has a combo box that holds names of employees. in the same form i have a...
|
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 date variable, the below code I'm using at the moment is:
if(date("dmY") == date("dmY", strtotime($datetimeIn)))
$datetime = 'Today @ '.date("H:i", strtotime($datetimeIn));
else if((date("d")-1).date("mY") == date("dmY",...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |