ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   days and months with heading zero from formula (https://www.excelbanter.com/excel-programming/427162-days-months-heading-zero-formula.html)

abc[_7_]

days and months with heading zero from formula
 
Hi all

I'm using this little formula to create a string that I use to do some
further computations

=YEAR(C88)&"-"&MONTH(C88)&"-"&DAY(C88)

the formula extracts the year,month,day from a date format cell like C88

that is MM/DD/YYYY

The problem is that if either the month or day are <10 I do not get the
heading zero from the formula.

example: C88=01/02/2003 ; my formula gives me a string 2003-2-1 instead
of 2003-02-01, which is what I need.

Is there any way to add the zero or extract the month and day so that
they keep the heading zero?

thanks


Jacob Skaria

days and months with heading zero from formula
 
Please try

=TEXT(C88,"YYYY-MM-DD")

If this post helps click Yes
---------------
Jacob Skaria


"abc" wrote:

Hi all

I'm using this little formula to create a string that I use to do some
further computations

=YEAR(C88)&"-"&MONTH(C88)&"-"&DAY(C88)

the formula extracts the year,month,day from a date format cell like C88

that is MM/DD/YYYY

The problem is that if either the month or day are <10 I do not get the
heading zero from the formula.

example: C88=01/02/2003 ; my formula gives me a string 2003-2-1 instead
of 2003-02-01, which is what I need.

Is there any way to add the zero or extract the month and day so that
they keep the heading zero?

thanks



abc[_7_]

days and months with heading zero from formula
 
Jacob Skaria wrote:
Please try

=TEXT(C88,"YYYY-MM-DD")

If this post helps click Yes
---------------
Jacob Skaria


Yes, that worked! Thanks a lot!


All times are GMT +1. The time now is 01:59 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com