datepart function

I

iccsi

I want to use datepart function to get date part always 2 digits like
following

DatePart("d", MyDate)

If MyDate is Jan/1/2011 then "01" but the function return "1"
Same as the month, I need get DatePart("m", MyDate) to return "01",
but not one.

I just wanted to know any option can do this or I need create my
function for this?

Your help is great appreciated,
 
M

Mike Painter

iccsi said:
I want to use datepart function to get date part always 2 digits like
following

DatePart("d", MyDate)

If MyDate is Jan/1/2011 then "01" but the function return "1"
Same as the month, I need get DatePart("m", MyDate) to return "01",
but not one.

Others have shown a couple methods but it is important for you to realize
that datepart returns a number.
Numbers are always 1,2,3,4 etc. and formatting is the only way to geet
leading zeros.
 
I

iccsi

Others have shown a couple methods but it is important for you to realize
that datepart returns a number.
Numbers are always 1,2,3,4 etc. and formatting is the only way to geet
leading zeros.

Thanks a millions for helping,
 

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