Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel: Leading Zeros on Dates.. Formula to do it for me?

Is there a way to add a leading zero to a date that is 7 digits and should be 8?

7301982 should be 07301982.

I have a column full of these values, and need a way to do so with a formula. Any ideas?

like image 821
jlrolin Avatar asked Oct 07 '09 18:10

jlrolin


People also ask

What is the formula to add leading zeros in Excel?

Here is how this formula works: You can change this according to your data. =REPT(0,5-LEN(A2))&A2 would simply add the number of zeroes to the value of the cell. For example, if the value in the cell is 123, this would return 00123.

What is leading zeros in dates?

The day of the month. Single-digit days will have a leading zero. The abbreviated name of the day of the week.

How do I add leading zeros to multiple cells in Excel?

Apply Custom Format with Leading Zeros Select the cell in which you want to add zeros as a prefix. Right click ➜ Format Option or you can also use the shortcut key Ctrl + 1 open “Format Cell Dialog Box”. In Category ➜ Select Custom. In the custom input dialog box, enter “0000000”.


1 Answers

I know this is an oldie, but when I googled for a solution this was the first result.

What I did was:

=concatenate(year(A1),text(month(A1),"00"),text(day(A1),"00"))

Where A1 is a date field.

like image 50
Zlatty Avatar answered Oct 30 '22 20:10

Zlatty