473,378 Members | 1,395 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,378 software developers and data experts.

Date difference

How can I calculate date-number of days?
Example:

Dim FirstDate as Date
Dim SecondDate as Date

FirstDate="01.12.2006"
SecondDate=FirstDate+2 '1 is number of days and I must get "03.12.2006"

or

SecondDate=FirstDate-5 ' and I will get "26.11.2006"

But it's not work! How can I calculate with dates in VB 2005?
Nov 20 '06 #1
1 1157
SecondDate = FirstDate.AddDays(2)
SecondDate = FirstDate.AddDays(-5)

--
Best regards | Schöne Grüße
Michael

Microsoft MVP - Most Valuable Professional
Microsoft MCAD - Certified Application Developer

http://weblogs.asp.net/mschwarz/
http://www.ajaxpro.info/


"Zile" <bo******@yahoo.comschrieb im Newsbeitrag
news:ej**********@sunce.iskon.hr...
How can I calculate date-number of days?
Example:

Dim FirstDate as Date
Dim SecondDate as Date

FirstDate="01.12.2006"
SecondDate=FirstDate+2 '1 is number of days and I must get "03.12.2006"

or

SecondDate=FirstDate-5 ' and I will get "26.11.2006"

But it's not work! How can I calculate with dates in VB 2005?

Nov 20 '06 #2

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

Similar topics

4
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and...
5
by: tamilan71 | last post by:
Hello All I have table with following fields: GroupId VisitDate 1 10/19/1993 1 11/24/1998 2 10/18/1993 2 10/29/1998 3 ...
7
by: Edward Mitchell | last post by:
I have a number of DateTimePicker controls, some set to dates, some set to a format of Time. The controls are all embedded in dialogs. I created the controls by dragging the DateTime picker from...
16
by: Atley | last post by:
I am trying to get a overall difference on two dates, I can get the difference in Years, Months, Weeks, Days, Hours, Minutes, Seconds, no problems... What I cannot seem to figure out is how to...
6
by: Scott | last post by:
I have a start date and an end date in my project that is defaulted to the current date at run-time using the following code... Date1.Value = Now() Date2.Value = Now() I then have some code...
13
by: priyasmita_guha | last post by:
Here is a program- /* PROGRAM: To find the difference between two dates */ #include<dos.h> #include<stdio.h> #include<conio.h> #include<process.h> void valid_date(int,int,int); int...
4
by: jamesyreid | last post by:
Hi, I'm really sorry to post this as I know it must have been asked countless times before, but I can't find an answer anywhere. Does anyone have a snippet of JavaScript code I could borrow...
3
by: bbawa1 | last post by:
Hi, I have a table which has a field ItemsReceived of type datetime. I have a grid view which has two columns. In first column i have to show the data from field ItemsReceived and in second...
7
by: rdawadiuk | last post by:
hi, I would like to calculate the date difference between two dates using field names which I have in my table. The field name is " Account opened on" for eg If the "Account open on" is Jan 5,...
6
by: krishnakant Mane | last post by:
hello, I am strangely confused with a date calculation problem. the point is that I want to calculate difference in two dates in days. there are two aspects to this problem. firstly, I can't get...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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...

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.