+ Reply to Thread
Results 1 to 6 of 6

Change a number into a date

  1. #1
    Forum Contributor
    Join Date
    12-14-2005
    Location
    US
    MS-Off Ver
    Excel 2019, Excel 365, Excel Mobile (Android)
    Posts
    193

    Change a number into a date

    When I import a txt file and convert into columns I have 1 column that is a text number (Ex. 20250222). What i need is a formula to convert that text into a date such that it becomes one of the following: 2025.02.22; or 02/22/2025. Maybe, this should be a VBA that executes on importing the date or with a macro button. Looking forward to some help.

  2. #2
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,443

    Re: Change a number into a date

    Will the text number always be 8 digits like you show here? In that case I expect something like =DATE(LEFT(textnumber,4),MID(textnumber,5,2),RIGHT(textnumber,2)) will return the desired date serial number, which you can then format in whatever date format you desire using number formatting.

    If you prefer VBA, VBA has similar text and date functions that can do the same thing.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  3. #3
    Forum Contributor
    Join Date
    12-14-2005
    Location
    US
    MS-Off Ver
    Excel 2019, Excel 365, Excel Mobile (Android)
    Posts
    193

    Re: Change a number into a date

    As I need to convert all records in Column E to the date format, VBA that would do the conversion as the data in converted from text file to columns might be best way going forward. Each import is over 2,000 records. Help is greatly appreciated.

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP, 2007, 2024
    Posts
    16,443

    Re: Change a number into a date

    Why do you think VBA would be best? I can enter that formula into a cell and copy/paste/fill down a lot faster than I can write a VBA procedure for that.

    As I said, VBA has the same basic functions. I would expect a similar VBA statement inside of a loop would work just fine.
    Please Login or Register  to view this content.
    It's up to you how you want to proceed. So far, I have not seen anything in your description of the problem that would suggest to me that VBA is a better programming language for this task than simple worksheet functions.

  5. #5
    Forum Guru
    Join Date
    04-23-2012
    Location
    New Jersey, USA
    MS-Off Ver
    Excel 365
    Posts
    2,475

    Re: Change a number into a date

    Quote Originally Posted by MrShorty View Post
    Will the text number always be 8 digits like you show here? In that case I expect something like =DATE(LEFT(textnumber,4),MID(textnumber,5,2),RIGHT(textnumber,2)) will return the desired date serial number, which you can then format in whatever date format you desire using number formatting.
    This shorter formula would also work the same way and handle the entire range all at once...

    =0+TEXT(A1:A2000,"0000-00-00")

    Note: Your formula will also handle the entire range all at once if you change each textnumber reference to the datarange reference.

  6. #6
    Forum Expert
    Join Date
    12-09-2014
    Location
    Trakai, Lithuania
    MS-Off Ver
    2016
    Posts
    1,418

    Re: Change a number into a date

    No formulas
    Text to Columns-->Delimeted-->Next-->Next-->Date--YMD--Finish
    Attached Files Attached Files

+ 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 number to date
    By scouse13 in forum Excel Formulas & Functions
    Replies: 12
    Last Post: 04-26-2018, 08:00 AM
  2. change date to number format
    By hktom in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 04-03-2018, 06:42 AM
  3. [SOLVED] change a number to a date
    By nicko54 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 10-09-2013, 06:07 PM
  4. change a number looking vs date
    By ukrockhit in forum Excel General
    Replies: 11
    Last Post: 05-19-2010, 06:54 AM
  5. Date change to number
    By minkey050705 in forum Excel General
    Replies: 1
    Last Post: 02-09-2010, 07:34 AM
  6. Change number to date
    By sioncleverly in forum Excel General
    Replies: 3
    Last Post: 03-13-2007, 12:15 PM
  7. Formula to change number into date
    By anjgoss in forum Excel General
    Replies: 4
    Last Post: 09-28-2005, 05:47 AM

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