+ Reply to Thread
Results 1 to 10 of 10

Need to change UK Date Format

  1. #1
    Registered User
    Join Date
    09-08-2018
    Location
    Los Angeles, CA
    MS-Off Ver
    Windows 10
    Posts
    7

    Need to change UK Date Format

    I have a .CSV file in UK date format of DD/MM/YYYY. I need to delete the DD and just have the MM/YYYY format instead. Thank you!

  2. #2
    Administrator FDibbins's Avatar
    Join Date
    12-29-2011
    Location
    Duncansville, PA USA
    MS-Off Ver
    Excel 7/10/13/16/365 (PC ver 2310)
    Posts
    52,926

    Re: Need to change UK Date Format

    This is probably already text (coming from a CSV file), but deleting the DD will for for sure make it text.

    What you need to understand about dates and times in excel is…

    a date is just a number representing the number of days passed since 1/1/900...and then formatted in a way that we recognize as a date. So, for instance, today (Mon 14 Sep 2020) is actually 44088

    Time is actually a decimal part of 1 (day), so 06:00 AM is 0.25, 12 noon is 0.5 and 18:00 (or 6 PM) is 0.75
    1. Use code tags for VBA. [code] Your Code [/code] (or use the # button)
    2. If your question is resolved, mark it SOLVED using the thread tools
    3. Click on the star if you think someone helped you

    Regards
    Ford

  3. #3
    Registered User
    Join Date
    09-08-2018
    Location
    Los Angeles, CA
    MS-Off Ver
    Windows 10
    Posts
    7

    Re: Need to change UK Date Format

    Thank you for your reply. I have thousands of lines with this date format and am hoping to avoid manual changes. Do you know if there's a way (perhaps a script) to achieve this?

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,811

    Re: Need to change UK Date Format

    As the say, the devil is in the details, and I am not sure I understand exactly what you want. You say that you want to "delete" the day information, but I wonder if you want to truly delete the day information, or if it is better to just "hide" the day information. To me, it usually seems preferable to keep the day information and just hide it rather than completely (and often permanently) deleting the information. With that in mind, here's how I would probably do it:

    1) Import the text file normally. As Ford explained, Excel will convert the date/time information into a serial number that it uses to store and work with date/time information. Assuming that your computer's regional settings are different from the source file, you will probably need to pay careful attention to this step to make sure that Excel reads the DMY data correctly. If you are uncertain how to do this, this thread had some good discussion about importing text files with dates and helping Excel import the dates correctly: https://www.excelforum.com/excel-gen...ml#post5364448

    2) With the dates imported correctly, then simple number formatting will easily display only the parts of the date that I want to see, while retaining all of the date/time information in the cell's value. Format as "mm/yyyy" to display only month/year for each date.

    It all depends on exactly what you are wanting to do when you say you want to "delete" the day information from the source data. I think it would be preferable to hide rather than delete, but you may have other ideas. If you can help us understand better exactly what you want to do, we should be able to help you.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  5. #5
    Registered User
    Join Date
    09-08-2018
    Location
    Los Angeles, CA
    MS-Off Ver
    Windows 10
    Posts
    7

    Re: Need to change UK Date Format

    I need to delete the day field for a software program that requires a mm/yyyy format to read the date. I don't think merely hiding it will satisfy the program. Thank you!

  6. #6
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,811

    Re: Need to change UK Date Format

    Still not sure I understand everything that is going on. Will this other program interact with Excel directly? If so, what is it looking to find in the Excel cells? Or are you needing to use Excel to create a new text file, and this program will interact with the text file?

  7. #7
    Registered User
    Join Date
    09-08-2018
    Location
    Los Angeles, CA
    MS-Off Ver
    Windows 10
    Posts
    7

    Re: Need to change UK Date Format

    The program will be uploading the information from the excel (.csv) file. If the file date is not in a mm/yyyy format, the software program will not read it.

  8. #8
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,811

    Re: Need to change UK Date Format

    But will the program be accessing the data directly in Excel, or will Excel be writing the data to a .csv (text) file, and the program accesses the data in the .csv file?

    Assuming the latter, then simply add a 3rd step to what I gave in post #4:
    3) File -> Save as -> file type comma separated values text (.csv) -> give it an appropriate file name.

    When Excel exports to a text/csv file, it writes the data as it is formatted in the cell. With a number format of "mm/yyyy", Excel should write that column to csv as formatted (you can open the exported file in a text editor to verify).

    Is that what you need to do?

  9. #9
    Registered User
    Join Date
    09-08-2018
    Location
    Los Angeles, CA
    MS-Off Ver
    Windows 10
    Posts
    7

    Re: Need to change UK Date Format

    Looping back to my original post, the .csv file was delivered in the DD/MM/YYYY format. In order for the software program I use to import the data, I need Excel to remove the DD and only have MM/YYYY.

  10. #10
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,811

    Re: Need to change UK Date Format

    If you follow the steps I outlined (keys: make sure Excel correctly imports the dates as real date serial numbers and make sure the number format on the date column is "mm/yyyy"), the new text/csv file should have text dates in MM/YYYY format. If you want to overwrite the old file rather than save as a new file, you can use File->Save instead of Save As or otherwise overwrite the old file.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. change date format in VBA code it means change output when printing cheque
    By keshavtale in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 12-23-2019, 06:06 AM
  2. Change format to date format if cell populated with a date
    By Lbelden78 in forum Hello..Introduce yourself
    Replies: 2
    Last Post: 07-22-2019, 08:26 AM
  3. Show Error when a cell with number format change to date format
    By delroba in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 03-08-2015, 02:57 AM
  4. [SOLVED] Date formula - Change Format to YYYYMMDD from Exported Format
    By haleakala17 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-21-2014, 03:22 PM
  5. [SOLVED] help on vba code to change the error date format as standard format mm/dd/yyyy
    By johnodys in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 11-13-2013, 01:10 AM
  6. Not able to change date format into proper excel date format
    By excel5111987 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 01-18-2011, 08:19 AM
  7. Userform date format reverting back to us format on change event
    By jpruffle in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-10-2009, 12:34 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1