how to get month and year from date

I

ina

Hello,

I would like to get the begin of the next month for each month since
one particular date until now

Sub Time()

Dim datFirst, dataSecond, monthnow, yearnow As Date
Dim year, month as String

datFirst = # 1/+month+/+Year+#

datsecond = Now

End sub

If the input value is = 15/02/2006

the result are

01/03/2006
01/04/2006
01/05/2006

I really do not know how to do it. Could someone help me please?

Ina
 
B

Bob Phillips

Sub Time(InputDate)
Dim datFirst as Date
Dim datSecond As Date
Dim datThird As Date

datFirst = DateSerial(Year(InputDate),Month(InputDate)+1,1)

datSecond = DateSerial(Year(InputDate),Month(InputDate)+2,1)

datThird = DateSerial(Year(InputDate),Month(InputDate)+3,1)

End Sub

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 
I

ina

thank you a log but I would like to use datediff between the first date
and and now today but I have a strange result I do not undestand why

Do While datedifferencee > 0

currendatemonth = Month(currentdate)
currentdateyear = Year(currentdate)


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

datedifferencee = CInt(difference)


currentdate = DateSerial(Year(currentdate), Month(currentdate) + i, 0)


currendatemonth = currendatemonth + 1

Loop

Ina
 
B

Bob Phillips

Now is Date not todaydate. Also your code makes no sense to me, I am not
seeing the link between this code and your original request. What exactly
are you trying to do?

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top