Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Calculating total days from 2 dates


Currently, I'm stuck in calculating the total days from 2 dates.
Let say I have *Startdate in A1*, *Enddate in B1* and the *total days
in C1*, how would I write it in VBA?

I tried using the formulas in the cells like below:

eg: Start Date=15.Nov.03 ; Enddate=30.Dec.03

in Cell C1:
=Day(B1)-Day(A1)
This gives me *16.Jan.00* as the answer!!

Plz help! thx!!


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from http://www.ExcelForum.com/

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Calculating total days from 2 dates

Hi,
Cell A1 : 15.Nov.03
Cell A2 : 30.Dec.03
Cell A3 : =A2-A1. This cell must be defined as "General"
or "number" for its format cell.
NicoB.

-----Original Message-----

Currently, I'm stuck in calculating the total days from 2

dates.
Let say I have *Startdate in A1*, *Enddate in B1* and the

*total days
in C1*, how would I write it in VBA?

I tried using the formulas in the cells like below:

eg: Start Date=15.Nov.03 ; Enddate=30.Dec.03

in Cell C1:
=Day(B1)-Day(A1)
This gives me *16.Jan.00* as the answer!!

Plz help! thx!!


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from

http://www.ExcelForum.com/

.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 391
Default Calculating total days from 2 dates

SUB GetDates()

Dim Date1 As Date, Date2 As Date
Dim Total as Long

Date1 = CDate(Range("A1").Value)
Date2 = CDate(Range("B1").Value)

Total = Date2 - Date1

Range("C1").Value = Total

END SUB

Alternative

SUB DateDiff()

Range("C1").Fromular1C1="=RC2-RC1"

End Sub

The first procedure calculates the diffrence and places
the result into C1
The second sub places your formula into C1


HTH
Patrick Molloy
Microsoft Excel MVP

-----Original Message-----



Currently, I'm stuck in calculating the total days from

2 dates.
Let say I have *Startdate in A1*, *Enddate in B1* and

the *total days
in C1*, how would I write it in VBA?

I tried using the formulas in the cells like below:

eg: Start Date=15.Nov.03 ; Enddate=30.Dec.03

in Cell C1:
=Day(B1)-Day(A1)
This gives me *16.Jan.00* as the answer!!

Plz help! thx!!


------------------------------------------------
~~ Message posted from http://www.ExcelTip.com/
~~View and post usenet messages directly from

http://www.ExcelForum.com/

.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Calculating total number of days in rolling year Suede Excel Worksheet Functions 1 December 1st 09 02:46 AM
Calculating the days between two dates pandd15 Excel Worksheet Functions 2 September 15th 09 03:18 PM
Calculating total number of days mac56er Excel Worksheet Functions 3 June 27th 08 06:56 PM
Conditional Formatting Dates calculating 10 days and 30 days from a certain date Sioux[_2_] Excel Worksheet Functions 2 October 11th 07 02:04 PM
Calculating number of days between two dates that fall between two other dates [email protected] Excel Discussion (Misc queries) 5 October 26th 05 06:18 PM


All times are GMT +1. The time now is 03:56 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"