#1   Report Post  
Posted to microsoft.public.excel.programming
TO TO is offline
external usenet poster
 
Posts: 6
Default date format

Hello All,

I have some code that places the numeric value of the
current month (i.e. 12, 11) in a combo box when the
userform is activated. I would like it to show a "0" in
front of the single-digit months (09). I am using the
following code on userform activate.

cmbPer.Value = Format(Date, "mm")

I am using a combo box to give the user the option of
selecting a different month, if necessary.
Thanks
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default date format

Think you are already there. From the immediate window:

dt = dateserial(2004,2,3)
? Format(dt, "mm")
02


--
Regards,
Tom Ogilvy

"TO" wrote in message
...
Hello All,

I have some code that places the numeric value of the
current month (i.e. 12, 11) in a combo box when the
userform is activated. I would like it to show a "0" in
front of the single-digit months (09). I am using the
following code on userform activate.

cmbPer.Value = Format(Date, "mm")

I am using a combo box to give the user the option of
selecting a different month, if necessary.
Thanks



  #3   Report Post  
Posted to microsoft.public.excel.programming
TO TO is offline
external usenet poster
 
Posts: 6
Default date format


cmbPer.Value = Format(Date, "mm")-1

this is exactly how I am doing it. My fiscal year starts
in Feb so Oct is actually per 9, but my result is "9"
not "09". Any thoughts?


-----Original Message-----
Think you are already there. From the immediate window:

dt = dateserial(2004,2,3)
? Format(dt, "mm")
02


--
Regards,
Tom Ogilvy

"TO" wrote in

message
...
Hello All,

I have some code that places the numeric value of the
current month (i.e. 12, 11) in a combo box when the
userform is activated. I would like it to show a "0"

in
front of the single-digit months (09). I am using the
following code on userform activate.

cmbPer.Value = Format(Date, "mm")

I am using a combo box to give the user the option of
selecting a different month, if necessary.
Thanks



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default date format

The apparent solution would be to subtract inside the format statement
cmbPer.Value = Format(Month(Date)-1, "mm")

but that won't handle the January.

cmbPer.Value = Format(DateSerial(Year(date),Month(date)-1,1),"mm")

Should be more robust.

--
Regards,
Tom Ogilvy



"TO" wrote in message
...

cmbPer.Value = Format(Date, "mm")-1

this is exactly how I am doing it. My fiscal year starts
in Feb so Oct is actually per 9, but my result is "9"
not "09". Any thoughts?


-----Original Message-----
Think you are already there. From the immediate window:

dt = dateserial(2004,2,3)
? Format(dt, "mm")
02


--
Regards,
Tom Ogilvy

"TO" wrote in

message
...
Hello All,

I have some code that places the numeric value of the
current month (i.e. 12, 11) in a combo box when the
userform is activated. I would like it to show a "0"

in
front of the single-digit months (09). I am using the
following code on userform activate.

cmbPer.Value = Format(Date, "mm")

I am using a combo box to give the user the option of
selecting a different month, if necessary.
Thanks



.



  #5   Report Post  
Posted to microsoft.public.excel.programming
TO TO is offline
external usenet poster
 
Posts: 6
Default date format

Excelent, thank you



-----Original Message-----
The apparent solution would be to subtract inside the

format statement
cmbPer.Value = Format(Month(Date)-1, "mm")

but that won't handle the January.

cmbPer.Value = Format(DateSerial(Year(date),Month(date)-

1,1),"mm")

Should be more robust.

--
Regards,
Tom Ogilvy



"TO" wrote in

message
...

cmbPer.Value = Format(Date, "mm")-1

this is exactly how I am doing it. My fiscal year

starts
in Feb so Oct is actually per 9, but my result is "9"
not "09". Any thoughts?


-----Original Message-----
Think you are already there. From the immediate

window:

dt = dateserial(2004,2,3)
? Format(dt, "mm")
02


--
Regards,
Tom Ogilvy

"TO" wrote in

message
...
Hello All,

I have some code that places the numeric value of

the
current month (i.e. 12, 11) in a combo box when the
userform is activated. I would like it to show

a "0"
in
front of the single-digit months (09). I am using

the
following code on userform activate.

cmbPer.Value = Format(Date, "mm")

I am using a combo box to give the user the option

of
selecting a different month, if necessary.
Thanks


.



.



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 50
Default date format

You can use the DateAdd function to add or subtract a specified time interval
from a date. This will take care of any January issues.

See help on this function

"TO" wrote:


cmbPer.Value = Format(Date, "mm")-1

this is exactly how I am doing it. My fiscal year starts
in Feb so Oct is actually per 9, but my result is "9"
not "09". Any thoughts?


-----Original Message-----
Think you are already there. From the immediate window:

dt = dateserial(2004,2,3)
? Format(dt, "mm")
02


--
Regards,
Tom Ogilvy

"TO" wrote in

message
...
Hello All,

I have some code that places the numeric value of the
current month (i.e. 12, 11) in a combo box when the
userform is activated. I would like it to show a "0"

in
front of the single-digit months (09). I am using the
following code on userform activate.

cmbPer.Value = Format(Date, "mm")

I am using a combo box to give the user the option of
selecting a different month, if necessary.
Thanks



.


  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default date format

That's certainly another way:

dt = DateSerial(2005,1,1)
? DateAdd("m",-1,dt)
12/1/2004


--
Regards,
Tom Ogilvy

"Datasort" wrote in message
...
You can use the DateAdd function to add or subtract a specified time

interval
from a date. This will take care of any January issues.

See help on this function

"TO" wrote:


cmbPer.Value = Format(Date, "mm")-1

this is exactly how I am doing it. My fiscal year starts
in Feb so Oct is actually per 9, but my result is "9"
not "09". Any thoughts?


-----Original Message-----
Think you are already there. From the immediate window:

dt = dateserial(2004,2,3)
? Format(dt, "mm")
02


--
Regards,
Tom Ogilvy

"TO" wrote in

message
...
Hello All,

I have some code that places the numeric value of the
current month (i.e. 12, 11) in a combo box when the
userform is activated. I would like it to show a "0"

in
front of the single-digit months (09). I am using the
following code on userform activate.

cmbPer.Value = Format(Date, "mm")

I am using a combo box to give the user the option of
selecting a different month, if necessary.
Thanks


.




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
permanent conversion of 1904 date format to 1900 date format Jos Excel Worksheet Functions 4 November 26th 15 02:48 PM
Convert european foreign date format to US date format EAL Excel Worksheet Functions 1 May 14th 09 10:02 PM
Convert date + time text format to date format Paul Ho Excel Worksheet Functions 2 May 22nd 07 05:47 PM
code to convert date from TEXT format (03-02) to DATE format (200203) Gauthier[_2_] Excel Programming 0 September 22nd 04 03:26 PM
Change a date in text format xx.xx.20xx to a recognised date format concatenator Excel Programming 1 November 24th 03 11:33 PM


All times are GMT +1. The time now is 08:21 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"