logo elektroda
logo elektroda
X
logo elektroda

Excel: Convert 4/28/2012 10:01:28 AM to 04-2012 Format Using Formulas & Next Cell Techniques

adamza 19806 14
ADVERTISEMENT
Treść została przetłumaczona polish » english Zobacz oryginalną wersję tematu
  • #1 10838177
    adamza
    Level 12  
    Hello,

    My date format is: 4/28/2012 10:01:28 AM.
    How to remove the day and time from the cell so that the date 04-2012 is created?
    It's not that it doesn't appear, it just disappears.
    Ev. what formula to use to make 04-2012 appear in the next cell.
    = DATE (YEAR .... does not help.
    Have any ideas?

    PS. sorry but i'm not an advanced user of excel, google doesn't help me either.
  • ADVERTISEMENT
  • #2 10838214
    pitermxa
    Level 18  
    Right click on the cell-> cell format-> custom and type with your finger or find in the list -> this: "mmm-ry"
  • #3 10838234
    adamza
    Level 12  
    It's not about not showing up, just that everything just disappears.
    When I use the formatting, the value remains and only will not be displayed.
    Then I have to make a graph of it, so I only need a month and a year
  • Helpful post
    #4 10839003
    marek003
    Level 40  
    If the date will be in A1 and only 04-2012 is to be displayed then:
    = MONTH (A1) & "-" & YEAR (A1)

    But this will not necessarily work for a given chart (It depends what chart and what it really is supposed to represent).

    Let me give you a hint that you'd better use custom formatting (as advised by my colleague pitermxa [only mm-yyyy or m-yyyy] ) and do the same formatting for this data in the graph (right-click on a given axis with dates in the chart and number format and set custom to mm-yyyy or m-yyyy there)

    Enclosed is an example in two versions with a simple diagram.
  • #5 10873655
    adamza
    Level 12  
    Thanks a lot, formula = MONTH (A1) & "-" & YEAR (A1) works
    but I have another problem because I can't format these cells and the date is 5-2012 and I would like it to be 05-2012 because later in the pivot table I get a mess. Can you do something about it?

    Added after 2 [minutes]:

    file in attachment
  • ADVERTISEMENT
  • #6 10873681
    adamza
    Level 12  
    BTW. to moderators, maybe it's time to allow adding * .xlsx files?
  • ADVERTISEMENT
  • #7 10873724
    roofy_1
    Level 17  
    do something like this
    = (IF (MONTH (A2)
  • #8 10873815
    adamza
    Level 12  
    ok thanks but in the pivot chart I still have 5-2012, 3-2011 etc. moreover, how to sort by dates from the newest in the chart?
  • #9 10873830
    roofy_1
    Level 17  
    copy this column and paste only the values from this column and on its basis then make a pivot table and it should be ok
  • #10 10873943
    adamza
    Level 12  
    the blood sausage comes out, see 2010, on 9-2010, when it copies the content, excel does not convert it to a date (probably because the day is missing)
  • #11 10873967
    adamza
    Level 12  
    maybe to add to each month the day 01-05-2012, for example, so that excel would treat it as a date?
  • #12 10873994
    roofy_1
    Level 17  
    yes, but then it will sort by day of each year and the point is that it should sort chronologically, by date


    and the date must necessarily be in this format?
    I did something like this
  • #13 10874138
    adamza
    Level 12  
    thanks for the effort :) but the date is still not sorted.
    I have to do this report once a week, and it better looks professional.
    Thank you for all your help, I will keep looking.
  • ADVERTISEMENT
  • Helpful post
    #14 10874496
    marek003
    Level 40  
    The trouble is you want to "have a cookie and eat a cookie"
    First you get rid of the date and then you want to make it again (adding 1). It does it differently, only it won't be useful to you.

    For Excel, subsequent dates are consecutive numbers, starting from 1 for 01/01/1900, 2 for 02/01/1900 etc. The fact that you see it as a date is what you owe to the formatting.
    Unfortunately, the data cannot be formatted in the pivot itself, so you can see what the standard format for the date is set to (if the data is a date, you see year-month-day, otherwise you see a text string or numbers).

    If you want to group data after a month, you have to make concessions.
    The formula below (and the above) changes the date to a string similar to a date, but it is not a date (and "adding" a one to it will not change that either - it will still be a text string, not a date).
    The sorting of such data is therefore carried out according to the principle of text strings. In this case, the solution is to change the formula so that it shows first the year and then the month, ie: 2011-09

    Then you will have the order (the order of "dates" consistent with the order in the text string).

    = IF (MONTH (A2)
  • #15 10898190
    adamza
    Level 12  
    Cool, the last tip works great. Thanks a lot for contributing ;)

Topic summary

The discussion revolves around converting a date in Excel from the format "4/28/2012 10:01:28 AM" to "04-2012". The user seeks a formula to extract the month and year while removing the day and time. Various solutions are proposed, including using the formula =MONTH(A1) & "-" & YEAR(A1) to achieve the desired format. However, issues arise with formatting leading to inconsistent outputs like "5-2012" instead of "05-2012", which complicates pivot table operations. Suggestions include using custom formatting and ensuring that the data is treated as a date for proper sorting. The conversation highlights the challenges of manipulating date formats in Excel and the need for precise formatting to maintain data integrity in charts and pivot tables.
Summary generated by the language model.
ADVERTISEMENT