Datepart alternative

BigDelGooner

Board Regular
Joined
Aug 17, 2009
Messages
197
Hi all

I am sure there is a simple answer, as always, but I just cant figure it out.

I would like to return just the days of a date so for example today (03/10/2011 or 10/03/2011 for those of you in the US)...when I use the Datepart function below

Day = DatePart("D", Date)

It returns 3...however this is where my problem is. I would like it to return 03. Is there a simple alternative?

Thanks in advance
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
You can but it will return a string

Code:
aDay = Format(DatePart("D", Date), "00")
 
Upvote 0
Try it like this...

Code:
TheDay = Format(Date, "dd")
I did not use Day as the receiving variable name because Day is the name of a built-in VB function.
 
Upvote 0

Forum statistics

Threads
1,214,872
Messages
6,122,025
Members
449,060
Latest member
LinusJE

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top