+ Reply to Thread
Results 1 to 14 of 14

Formula to create a date from a cell value

  1. #1
    Registered User
    Join Date
    06-07-2016
    Location
    Richmond, VA
    MS-Off Ver
    365 Apps for business
    Posts
    82

    Formula to create a date from a cell value

    I'm copying data from an ad provider into a spreadsheet.

    I need to be able to use date filters on this data.

    Some date values from the provider are pasting in as Date, some are pasting in as General (column A).

    Even if I drag over those General types and change them to Date, I'm still unable to filter data based on Date values.

    Therefore I'm creating a new field (column F) to create a date a field from each of the values I'm pasting into column A.

    I need a formula that does this:
    - If cell A3 is already a date then replicate value of A3 in F3.
    - If cell A3 is not a date then take each of the numerical values in that call and create a date out of it in mm/dd/yyyy format.

    Can anyone help with that please?

    Date Help.xlsx
    Last edited by kimi01; 11-07-2022 at 12:21 PM.

  2. #2
    Banned User!
    Join Date
    02-05-2015
    Location
    San Escobar
    MS-Off Ver
    any on PC except 365
    Posts
    12,168

    Re: Formula to create a date from a cell value

    try text 2 columns and choose proper format for you: DMY or MDY or what ever

    date.png

  3. #3
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Formula to create a date from a cell value

    They all present correctly for me - they appear to be in dd/mm/yyyy format, which is what we use.

    Try this:

    1. Select column A.
    2. Data ribbon | Text to Columns.
    3. Click Next > Next > choose MDY > Finish.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  4. #4
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,427

    Re: Formula to create a date from a cell value

    Deleted. Simple formula is wrong approach. Use Text to Columns as advised.
    Last edited by TMS; 11-07-2022 at 12:31 PM.
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  5. #5
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Formula to create a date from a cell value

    - If cell A3 is already a date then replicate value of A3 in F3.
    You don't want to do this!

    A date that presents as, for example, 11/02/2022 will be read by your systam as 2nd November, but it isn't: it's 11th February. You'd end up with a lot of incorrect data!

    Use the process that Sandy and I have showed you.

  6. #6
    Registered User
    Join Date
    06-07-2016
    Location
    Richmond, VA
    MS-Off Ver
    365 Apps for business
    Posts
    82

    Re: Formula to create a date from a cell value

    Thanks for the replies!

    I have tried using the Text to Columns solution and while the date data presents correctly as Date, if I try and filter the data the filter is still seeing it as General and so offers no date type filters.

    Attachment 804003

  7. #7
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Formula to create a date from a cell value

    Try this in another column dragged down AFTER DOING TEXT TO COLUMNS:

    =A3+0

    Is that column seen correctly?

  8. #8
    Registered User
    Join Date
    06-07-2016
    Location
    Richmond, VA
    MS-Off Ver
    365 Apps for business
    Posts
    82

    Re: Formula to create a date from a cell value

    Quote Originally Posted by AliGW View Post
    Try this in another column dragged down AFTER DOING TEXT TO COLUMNS:

    =A3+0

    Is that column seen correctly?
    In the attached, cell A5 to A8 are pasting in as General. I used the Text to Column fix on these cells, as you can see, they're showing as being Date.

    When I use the further =A5+0 solution however, I get an error.

    Attachment 804008

  9. #9
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Formula to create a date from a cell value

    You need to run text to columns on the whole of column A.

  10. #10
    Registered User
    Join Date
    06-07-2016
    Location
    Richmond, VA
    MS-Off Ver
    365 Apps for business
    Posts
    82

    Re: Formula to create a date from a cell value

    Quote Originally Posted by AliGW View Post
    You need to run text to volume on the whole of column A.
    Sorry, I wasn't clear. That has been done

  11. #11
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,780

    Re: Formula to create a date from a cell value

    Share a workbook.

  12. #12
    Registered User
    Join Date
    06-07-2016
    Location
    Richmond, VA
    MS-Off Ver
    365 Apps for business
    Posts
    82

    Re: Formula to create a date from a cell value

    Quote Originally Posted by AliGW View Post
    Share a workbook.
    Sure, here to you go - thanks!

    Date Help.xlsx

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

    Re: Formula to create a date from a cell value

    I feel like something must have gone wrong when you executed the text to columns, because an ISTEXT(A3) [copied down] shows that everything from row 5 down is still text and not date/number. I also notice that row 3 is now 11 May 2022 and row 4 is 11 Feb 2022, when I think the original data intended these to be 5 November and 2 November.

    Noting the error in AliGW's post (post #3 set date format to MDY) that is correct in Sandy666's post (post #2 set date format to DMY) during the text to columns/step 3 of the text import wizard, I believe that you failed to set the correct input date format when you went through the text import wizard. Start over with the original text data, and pay careful attention on step three of the text import wizard to the actual date format as it is in the text string -- specifically DMY.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  14. #14
    Registered User
    Join Date
    06-07-2016
    Location
    Richmond, VA
    MS-Off Ver
    365 Apps for business
    Posts
    82

    Re: Formula to create a date from a cell value

    Quote Originally Posted by MrShorty View Post
    I feel like something must have gone wrong when you executed the text to columns, because an ISTEXT(A3) [copied down] shows that everything from row 5 down is still text and not date/number. I also notice that row 3 is now 11 May 2022 and row 4 is 11 Feb 2022, when I think the original data intended these to be 5 November and 2 November.

    Noting the error in AliGW's post (post #3 set date format to MDY) that is correct in Sandy666's post (post #2 set date format to DMY) during the text to columns/step 3 of the text import wizard, I believe that you failed to set the correct input date format when you went through the text import wizard. Start over with the original text data, and pay careful attention on step three of the text import wizard to the actual date format as it is in the text string -- specifically DMY.
    Thanks!

    I see the problem.

    The data was exporting in dd/mm/yyy, I was expecting it in mm/dd/yyyy. I'm a Brit living in the US so I frequently glaze over those differences in date data.

    All sorted now - it's always something embarrassingly obvious!

+ 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. [SOLVED] Formula to create a new date by adding to an original date
    By shaunaa in forum Excel Formulas & Functions
    Replies: 19
    Last Post: 01-20-2018, 07:38 PM
  2. How do I use a date typed in a cell to create a range for another formula?
    By Hstclair05 in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 02-01-2016, 05:48 PM
  3. [SOLVED] Formula to use numbers from left and right of cell to create a date
    By maryren in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 09-19-2013, 04:03 PM
  4. Replies: 2
    Last Post: 04-08-2007, 02:21 PM
  5. [SOLVED] Help to create a date formula
    By S S in forum Excel Formulas & Functions
    Replies: 6
    Last Post: 07-24-2006, 02:20 AM
  6. [SOLVED] Create a button that will date stamp todays date in a cell
    By Tom Meacham in forum Excel General
    Replies: 3
    Last Post: 01-10-2006, 09:10 PM
  7. Replies: 1
    Last Post: 02-15-2005, 12:06 AM

Tags for this Thread

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