473,414 Members | 1,665 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Date calculations.

In VB6.0 I Did This operation with dates.
Dim d as String
D=Date
D=D-1

or
D=D+1

In Vb.2003
Dim d As String
d = Microsoft.VisualBasic.Today.Date-1
and I received a error.
Who this work in Vb.2003?

Thanks.

Nov 30 '05 #1
5 1892
You need to use the DateAdd() function (in Microsoft.VisualBasic namespace) ...

Dim d As Date
d = DateAdd(Microsoft.VisualBasic.DateInterval.Day, 1, Date.Now)

"Miguel Arenas" wrote:
In VB6.0 I Did This operation with dates.
Dim d as String
D=Date
D=D-1

or
D=D+1

In Vb.2003
Dim d As String
d = Microsoft.VisualBasic.Today.Date-1
and I received a error.
Who this work in Vb.2003?

Thanks.

Nov 30 '05 #2
Or you can use some of the built in methods of the DateTime structure:

Dim d As Date = DateTime.Now

d = d.AddSeconds(10) 'Advances the datetime by 10 seconds
d = d.AddHours(1) 'Advances the datetime by 1 hour
d = d.AddDays(1) 'Advances the date by 1 day
d = d.AddDays(-1) 'Decreases the date by 1 day

Nov 30 '05 #3
But how can I substract one day?

"Chris Dunaway" wrote:
Or you can use some of the built in methods of the DateTime structure:

Dim d As Date = DateTime.Now

d = d.AddSeconds(10) 'Advances the datetime by 10 seconds
d = d.AddHours(1) 'Advances the datetime by 1 hour
d = d.AddDays(1) 'Advances the date by 1 day
d = d.AddDays(-1) 'Decreases the date by 1 day

Nov 30 '05 #4
d = d.AddDays(-1)

Nov 30 '05 #5
On 30/11/2005 Miguel Arenas wrote:

"Chris Dunaway" wrote:
d = d.AddDays(-1) 'Decreases the date by 1 day

But how can I substract one day?


It was in Chris's post :-)

--
Jeff Gaines
Nov 30 '05 #6

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

Similar topics

1
by: Marc | last post by:
I've got a PHP script that's using fopen to connect to a remote web server and pick up data. I've run into a problem in calculating elapsed time. The remote web server outputs a time and I'd...
13
by: perplexed | last post by:
How do you convert a user inputted date to a unix timestamp before insterting it into your database? I have a form, with a textfield for a date that the user inputs in the format mm-dd-yyyy and...
2
by: androtech | last post by:
Hello, I'm looking for a function that returns a date range for a specified week number of the year. I'm not able to find functions like this anywhere. Any pointers/help would be much...
30
by: Dr John Stockton | last post by:
It has appeared that ancient sources give a method for Numeric Date Validation that involves numerous tests to determine month length; versions are often posted by incomers here. That sort of code...
11
by: lduperval | last post by:
Hi, I`m trying to do date calculations in three types of time zones: local, GMT and specified. The issue I am facing is that I need to be able to specify a date in the proper time zone, and I`m...
2
by: Joe Jax | last post by:
I have some date calculations that add a time span to a date. The problem is, when I add a time span that is a whole number of days to a date, the result can be +/- 1 hour due to daylight savings....
1
by: bluerocket | last post by:
I have searched this group, and am not finding the answer I am looking for -- hope you can help. I have a front-end MS Access database hooked via a MyODBC link to a MySQL database. A modified...
5
by: Simon Dean | last post by:
Probably being a little thick here, but when you subtract one date away from another, how do you convert the resultant value into a number of days... I guess I could easily / 60 / 60 / 24... but...
3
by: Glencannon4424 via AccessMonster.com | last post by:
Hello, I have what I believe amounts to a Date Serial issue. I have the following columns in my table: Hire-Date Hire-Year WTD-RATE Wks-in-Yr
8
by: Charlie Brookhart | last post by:
I am creating a program that involves having to find the difference between two dates and converting it to a number to be used for calculations. The problem is that the way it is setup, VB is not...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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
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...

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.