calculating month of present date

A

anu_manu

Hey all
please let me know how can i calculate month of present date in VBA.
At present i can have the first date and present date by
txtStartDate = Format(Date - Day(Date) + 1, "dd/mm/yyyy")
txtEndDate = Format(Date, "dd/mm/yyyy").

but now i want to calculate MONTH of present date.

please help
thanks in advance
 
B

Bob Phillips

txtMonth.Text = Month(Date)

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)
 
A

anu_manu

Thanks Bob
But Month(date) returns 01/01/1900 and not 02/01/2006. why is that so?
Thanks
 
G

Guest

It is returning an integer, but you've got the cell formatted as date.
Change the format to general or number and you'll get the date
 
A

anu_manu

i format it as this

Format(month(date),"mm/dd/yyyy")

isn't it right?

Actually,my problem is this..

Currently the Start Date defaults to the first day of the current
month.
The request is to default the start date to the first day of the
quarter
(e.g. 01.01, 04.01,07.01,10.01... +year).

If the current month is between 1 and 3, default is 01.01.+current
year
If the current month is between 4 and 6, default is 04.01.+current
year

Please kindly guide.
 
B

Bob Phillips

StartDate = DateSerial(Year(StartDate), (Month(StartDate) + 2) \ 3, 1)


--
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