LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
ina ina is offline
external usenet poster
 
Posts: 120
Default datediff help

Hello,

I have this sub which needs to give me each end of month between the
first date and now


Dim diffdatemonth()
dim currentdate, todaydate as date
dim currentmonth, todaymonth, currentyear as date
dim inceptiondate as date
dim difference as string
dim i as integer
dim datedifference as integer

inceptiondate = "2006/01/06"

todaydate = Now()


currentdate = DateSerial(Year(inceptiondatedate), Month(inceptiondate)
+ 1, 0)
' the current date it is the first end of month so here I would like to
have 2006/01/31

currentmonth = Month(currentdate)
todaymonth = Month(todaydate)

datedifference = 1

i = 1



'until the difference beetween currentdate and todaydate it is greater
than 0


Do While datedifference 0

currentmonth = Month(currentdate)
currentyear = Year(currentdate)


difference = datediff("d", todaydate, currentdate)

datedifferencee = CInt(difference)

currentdate = DateSerial(currentyear, (currentmonth + i), 1)

difference = datediff("m", todaydate, currentdate)

datedifference = CInt(difference)

currentmonth = currentmonth + 1

Loop


End Sub

I have something wrong in this code and I do not understand why; could
someone to help me

Ina

 
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
DateDIFF Paul Breslin Excel Programming 1 December 12th 05 03:09 PM
datediff in excel 2003.. Agecalculation -[::::Shamran::::]- Excel Programming 5 March 12th 05 11:33 AM
Help with datediff vba John Excel Programming 4 February 16th 05 01:56 PM
DateDiff in Excel JE McGimpsey Excel Programming 0 May 11th 04 05:07 PM
DateDiff problem Antje Crawford Excel Programming 3 July 8th 03 09:44 PM


All times are GMT +1. The time now is 11:59 AM.

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"