Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
anu_manu
 
Posts: n/a
Default calculating month of present date


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


--
anu_manu
------------------------------------------------------------------------
anu_manu's Profile: http://www.excelforum.com/member.php...o&userid=31510
View this thread: http://www.excelforum.com/showthread...hreadid=516246

  #2   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default calculating month of present date

txtMonth.Text = Month(Date)

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"anu_manu" wrote in
message ...

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


--
anu_manu
------------------------------------------------------------------------
anu_manu's Profile:

http://www.excelforum.com/member.php...o&userid=31510
View this thread: http://www.excelforum.com/showthread...hreadid=516246



  #3   Report Post  
Posted to microsoft.public.excel.misc
anu_manu
 
Posts: n/a
Default calculating month of present date


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


--
anu_manu
------------------------------------------------------------------------
anu_manu's Profile: http://www.excelforum.com/member.php...o&userid=31510
View this thread: http://www.excelforum.com/showthread...hreadid=516246

  #4   Report Post  
Posted to microsoft.public.excel.misc
Duke Carey
 
Posts: n/a
Default calculating month of present date

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

"anu_manu" wrote:


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


--
anu_manu
------------------------------------------------------------------------
anu_manu's Profile: http://www.excelforum.com/member.php...o&userid=31510
View this thread: http://www.excelforum.com/showthread...hreadid=516246


  #5   Report Post  
Posted to microsoft.public.excel.misc
anu_manu
 
Posts: n/a
Default calculating month of present date


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.


--
anu_manu
------------------------------------------------------------------------
anu_manu's Profile: http://www.excelforum.com/member.php...o&userid=31510
View this thread: http://www.excelforum.com/showthread...hreadid=516246



  #6   Report Post  
Posted to microsoft.public.excel.misc
Bob Phillips
 
Posts: n/a
Default calculating month of present date

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


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"anu_manu" wrote in
message ...

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.


--
anu_manu
------------------------------------------------------------------------
anu_manu's Profile:

http://www.excelforum.com/member.php...o&userid=31510
View this thread: http://www.excelforum.com/showthread...hreadid=516246



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
Changing a date back one month John Excel Discussion (Misc queries) 7 February 7th 06 12:11 PM
4 and 5 week months Big Rick Excel Discussion (Misc queries) 15 November 7th 05 12:32 AM
Round date to first of month Dominic Excel Discussion (Misc queries) 3 July 14th 05 11:21 PM
How do I show dates older than present date? Sissyfirst Excel Worksheet Functions 1 July 12th 05 09:56 PM
Formula for Extracting Month out of a Date column PokerZan Excel Discussion (Misc queries) 3 June 10th 05 08:30 PM


All times are GMT +1. The time now is 10:17 PM.

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

About Us

"It's about Microsoft Excel"