Skip to main content

Posts

Showing posts with the label formula

Working with the Date in Excel

I was just asked by my colleague how to turn 20080101 (in a file provided by a client) to 01/01/2008 (to be used in our system) in Excel where the cell is presented as text. We can easily recognise the date, but computers are not so intelligent to put up with these variations of how we operate. There are a number of ways, but mine relies on certain assumptions, that numbers below 10 are pre-padded with a zero (0), ie. the 9th is represented as 09. This method uses the VB functions in Excel, but for simpilicity's sake I will break this down into stages. For this example, I will use the above date (20080101) which is in cell A1. Firstly, we need to split the date in and use cells A4, B4, and C4: So we need to use a formula in A4 to get the year, B4 to get the month and C4 to get the day: Year =LEFT(A1,4) Month =MID(A1,5,2) Day = RIGHT(A1,2) The LEFT function is to get the first four digits. The MID function is to get the middle 2 digits starting from the 5th position. The RIGH...