+ Reply to Thread
Results 1 to 17 of 17

Cant get my head around this date issue

  1. #1
    Registered User
    Join Date
    09-01-2016
    Location
    Scotland
    MS-Off Ver
    2013
    Posts
    8

    Cant get my head around this date issue

    Hello,

    I am in the UK, my regional settings are UK, so date is dd/mm/yyyy and the location is set to united kingdom


    I have some data which I am pasting into an unformatted excel table, when pasting the data the date automatically gets the united states format 3/14/2016 1:30pm, when I try and use the =text(cell,"mmm") formula to get the month I just get the original date. If I type over the original date in a UK format 14/3/2016, the actual date format shown stays as the US and also the format in the cell stays as US but I can now get the month using the =text(), I have also tried =month().

    can anyone recommend how I can resolve this so I do not have to retype all of the dates, I have attached an example showing the change after I key the date as UK format so you can see the formula working.

    Thanks for any help

    Dex
    Attached Files Attached Files

  2. #2
    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,447

    Re: Cant get my head around this date issue

    The cells might be formatted as Date but they don't contain a Date, or a Date/Time. They contain a Text string which, nominally, represents a Date and Time.

    You'd need to do some extracting, I think, to get the date out of that.
    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


  3. #3
    Valued Forum Contributor loginjmor's Avatar
    Join Date
    01-31-2013
    Location
    Cedar Rapids, Iowa
    MS-Off Ver
    Excel 2013
    Posts
    1,073

    Re: Cant get my head around this date issue

    Hi -

    Part of the problem is most of the information in the left hand column is text, rather than a true date. Excel uses serial numbers to represent dates, and then you format the cell the way you want to display it. As a test, highlight the cells in the left column and change the format to Number. The ones that change to a number (e.g., 42601 is August 19) are the only ones that will respond to your TEXT formula and your formatting. I suspect either your copying and pasting operation is somehow pasting as text, OR the raw data isn't numeric either (i.e., mixed text and numbers).

    As a workaround, you can use the DATEVALUE and TIMEVALUE functions to take text that looks like a date and time (which is what you have) and convert it into a date number and a time number (which will be a decimal value). Add the two together and you get a date and time number which you can then format to your heart's content.

    Hope this helps!
    ____________________________________________
    If this has solved your problem, please edit the thread title to add the word [SOLVED] at the beginning. You can do this by
    -Go to the top of the first post
    -Select Thread Tools
    -Select Mark thread as Solved

    If I have been particularly helpful, please "bump" my reputation by pressing the small star in the lower left corner of my post.

  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,447

    Re: Cant get my head around this date issue

    Actually, I lie. Most of the "dates" are not dates. The exception being the shorter examples which have 12:00 AM as the time. They are true dates.

  5. #5
    Registered User
    Join Date
    09-01-2016
    Location
    Scotland
    MS-Off Ver
    2013
    Posts
    8
    Quote Originally Posted by TMS View Post
    Actually, I lie. Most of the "dates" are not dates. The exception being the shorter examples which have 12:00 AM as the time. They are true dates.
    Thank you very much. I will try your solution tomorrow. the ones showing 12:00 AM are the ones I typed a uk date format into so it makes sense.

    thanks again

  6. #6
    Registered User
    Join Date
    09-01-2016
    Location
    Scotland
    MS-Off Ver
    2013
    Posts
    8
    Quote Originally Posted by loginjmor View Post
    Hi -

    Part of the problem is most of the information in the left hand column is text, rather than a true date. Excel uses serial numbers to represent dates, and then you format the cell the way you want to display it. As a test, highlight the cells in the left column and change the format to Number. The ones that change to a number (e.g., 42601 is August 19) are the only ones that will respond to your TEXT formula and your formatting. I suspect either your copying and pasting operation is somehow pasting as text, OR the raw data isn't numeric either (i.e., mixed text and numbers).

    As a workaround, you can use the DATEVALUE and TIMEVALUE functions to take text that looks like a date and time (which is what you have) and convert it into a date number and a time number (which will be a decimal value). Add the two together and you get a date and time number which you can then format to your heart's content.

    Hope this helps!
    thank you i will try this solution tomorrow

  7. #7
    Registered User
    Join Date
    09-01-2016
    Location
    Scotland
    MS-Off Ver
    2013
    Posts
    8

    Re: Cant get my head around this date issue

    Hello,

    Ok I tried the suggestion with Datevalue and timevalue but this did not do the trick, I was then reviewing issues on another website and came across a similar issue and when I tried that fix it never worked either... I was convinced that this had something to do with my regional settings being UK because lets say the cell content was 08/31/2016 10:00 am with a date format as US mm/dd/yyyy the formula's did not work but if I over typed I the following format 31/08/2016 10:00 am the formula did work despite the cell still displaying 08/31/2016 10:00 as the American format... anyway long story short is as soon as I changed the format, in the PC's regional settings to US the formula's work.

    There must be away to resolve this regional setting issue within excel without having to change the regional setting of the entire system, but as it stands I have not been able to find a solution.

    Thanks for your previous sugestions
    Dex

  8. #8
    Valued Forum Contributor
    Join Date
    11-22-2014
    Location
    Arizona, USA
    MS-Off Ver
    Office 365
    Posts
    973

    Re: Cant get my head around this date issue

    Hey DexterX,

    This is one of those things that most of us don't deal with because when we build a sheet it is designed in and for the location in which it is built.
    However this is a common issue primarily due to the Regional Settings, which would appear you have discovered.
    One method I found that worked for a similar issue was to use a Public Function and do my math all in VBA.
    Not only did I take care of a date issue, but by the end of the project there were less than 5 formulas that remained live in the workbook out of thousands... Cutting back on processing time significantly. (Whole different topic)

    If you want to test it out - you can add the public function. (Again this works in VBA, using it as a formula in cells will revert to local (regional) settings, so even though you say "DD/MM/YYYY" if coming from 9/2/2016 and it returns 02/09/2016...Excel will recognize it as Feb 9th... Inside VBA however it will store the proper date with formatting to later be used in any formula...

    Go to your developer window and enter into Visual basics (Or just hit [ALT]+[F11]
    Insert a new module in the project window (Right click on any visible sheet and select Insert>Module

    Inside the new window that appears input the following.
    Please Login or Register  to view this content.
    An example of this inside your code might be something like this
    Please Login or Register  to view this content.
    OR if you were taking it from a cell on sheet 1 in A1 it would be
    Please Login or Register  to view this content.
    And while the end result would be 02/09/2016 for a reference looking at today, it would retain its VBA.Format$ for you to utilize.

    Sounds like you may be satisfied with modifying your entire PC to live outside the UK superficially, but thought I would offer up another possible workaround. Depends on your ability/Comfort level with VBA though.

    Cheers
    -If you think you are done, Start over - ELeGault

  9. #9
    Registered User
    Join Date
    09-01-2016
    Location
    Scotland
    MS-Off Ver
    2013
    Posts
    8

    Re: Cant get my head around this date issue

    Thank you for the reply and the information, I will give this a go later tonight as this is an option as I am worried if I forward my sheet to someone else with UK settings then the results will be incorrect or the formulas broken when they open sheet
    Dex

  10. #10
    Forum Expert Sam Capricci's Avatar
    Join Date
    06-14-2012
    Location
    Palm Harbor, Florida
    MS-Off Ver
    16.84 for Mac MS 365
    Posts
    8,499

    Re: Cant get my head around this date issue

    I know this method gets scoffed at on this forum but without using VBA or formulas, what I've done many times is to highlight the entire column, then using find and replace start with find 0, replace with 0, hit replace all, then repeat through 9. It seems a bit repetitive but it clears out pesky text and replaces them with numbers and has worked every time I've tried it, FWIW. Make sure your settings are for any part of the cell.
    Make contributors happy, click on the "* Add Reputation" as a way to say thank you.
    Sam Capricci

  11. #11
    Registered User
    Join Date
    09-10-2016
    Location
    Amsterdam
    MS-Off Ver
    2016
    Posts
    6

    Re: Cant get my head around this date issue

    A bit of a simple method, you may have tried this already but its the first thing that I do before going to VBA solutions is the following:

    Insert 1 into any free cell
    copy the cell (with the value of 1)
    Select your date cells that are not working
    Paste Special and then select the option multiply

    Hope you manage to solve your problem...

  12. #12
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Cant get my head around this date issue

    Select col A, Data > Text to columns, Next, Next, select Date: MDY, press Finish.

    Repeat for col C.

    A
    B
    C
    D
    E
    F
    1
    Open Date Time
    the month
    Close Date Time
    Age
    2
    8/19/16 7:35 AM
    Aug
    8/22/16 7:10 AM
    71 H 35 M
    D2: =MROUND([@[Close Date Time]]-[@[Open Date Time]], "0:01")
    3
    8/19/16 12:00 AM
    Aug
    8/26/16 6:21 AM
    174 H 22 M
    Format of D2: [h]" H "m" M"
    4
    8/23/16 9:26 AM
    Aug
    8/24/16 4:52 AM
    19 H 26 M
    5
    8/22/16 11:25 AM
    Aug
    8/24/16 6:54 AM
    43 H 28 M
    6
    8/23/16 8:11 AM
    Aug
    8/25/16 10:04 AM
    49 H 53 M
    7
    8/19/16 6:01 AM
    Aug
    8/24/16 4:01 AM
    118 H 0 M
    8
    8/22/16 12:00 AM
    Aug
    8/25/16 7:16 AM
    79 H 16 M
    9
    3/3/16 12:00 AM
    Mar
    8/25/16 7:17 AM
    4207 H 17 M
    10
    8/23/16 10:56 AM
    Aug
    8/26/16 5:24 AM
    66 H 29 M
    11
    8/22/16 5:10 AM
    Aug
    8/25/16 10:24 AM
    77 H 14 M
    12
    8/16/16 4:40 AM
    Aug
    8/24/16 6:55 AM
    194 H 15 M
    Entia non sunt multiplicanda sine necessitate

  13. #13
    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,447

    Re: Cant get my head around this date issue

    I think Regional Settings is a bit of a red herring. You do NOT have a date and time in the cells. You have TEXT which looks, to all intents and purposes, like a date and time. Formatting will have no effect on the data in the cell, nor will arithmetic manipulation. A date and time would have a numeric content something like ddddd.ttttt.... It doesn't it has text and hence the formatting options will have no effect.

    For example, 11/09/2016 21:32:00, if formatted as General, would display 42624.8972222222. The 42624 is the number of days starting from 01/01/1900. The 0.8972222222 is a fraction representing part of a day, a 24 hour period.

    You can use a formula to extract the "date" part. Then you can use Copy and Paste Special | Values to convert that to Text. And finally, you can use Text to Columns to convert the column to a true date.

    Use this formula to extract the date: =LEFT([@[Open Date Time]],FIND(" ",[@[Open Date Time]])-1)

    Then select the whole column of data and use Copy and Paste Special | Values to paste the values over the original formulae

    Finally, use Text to Columns to convert the (still wrong format) "date" to true dates. See the updated example for detailed instructions.
    Attached Files Attached Files

  14. #14
    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,447

    Re: Cant get my head around this date issue

    @shg: Text to Columns on Column A didn't work for me. Hence my more convoluted approach. Could it be that Regional Settings does have a bearing on it given that you're in the Great State of Texas and the "dates" are in US format?

  15. #15
    Forum Expert shg's Avatar
    Join Date
    06-20-2007
    Location
    The Great State of Texas
    MS-Off Ver
    2003, 2010
    Posts
    40,678

    Re: Cant get my head around this date issue

    @ TMS: Thanks for the followup.

    @ Dex: I have no other suggestion.

  16. #16
    Forum Expert
    Join Date
    03-20-2015
    Location
    Primarily UK, sometimes NL
    MS-Off Ver
    Work: Office 365 / Home: Office 2010
    Posts
    2,405

    Re: Cant get my head around this date issue

    It's horrible, but I think this will work:

    To get the 'Open Date Time' as a combined date and time, use this:
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    To get the 'Close Date Time' as combined date and time, use the same with [Close Date Time] instead of [Open Date Time]:
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Format both columns as date and time (select 'Custom' then choose the one you want - I used d mmm yy\ hh:mm )

    I think that should work with your combination of UK/US formats / imported/manually typed dates/times, though I'm not 100% sure as it depends on exactly how your system is set-up.

    The difference between the date/times can be found using this (the formulae above are in columns titled 'DateTimeOpen' and 'DateTimeClose':
    Formula: copy to clipboard
    Please Login or Register  to view this content.


    I've attached a file showing these formulae working - they're in columns Y,Z,AA - the other columns (in small blue text) were the 'working' columns I used to develop them, in case you're interested


    Hope that helps!
    Regards,
    Aardigspook

    I recently started a new job so am a bit busy and may not reply quickly. Sorry - it's not personal - I will reply eventually.
    If your problem is solved, please go to 'Thread Tools' above your first post and 'Mark this Thread as Solved'.
    If you use commas as your decimal separator (1,23 instead of 1.23) then please replace commas with semi-colons in your formulae.
    You don't need to give me rep if I helped, but a thank-you is nice.

  17. #17
    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,447

    Re: Cant get my head around this date issue

    That is impressive, even if horrible.

+ 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. League Table Based on Head to Head results
    By darkblueblood in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-16-2023, 07:10 AM
  2. [SOLVED] Conditional formatting? if 3 teams head to head? Need highlight it
    By micope21 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-09-2016, 04:55 AM
  3. [SOLVED] How to insert a previous Head to head matches ?
    By malveiro in forum Excel General
    Replies: 7
    Last Post: 05-14-2015, 08:34 AM
  4. Breaking ties in a head to head contest
    By cklemme in forum Excel Formulas & Functions
    Replies: 13
    Last Post: 01-28-2014, 01:06 AM
  5. How to account for head to head matchup in Excel with other tie breakers
    By Biogeek1 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 11-26-2013, 05:18 PM
  6. Calculate average of last two outcomes of last two head-to-head clashes
    By wishkey in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 05-07-2013, 08:17 AM
  7. Ranking a league table by head to head results
    By pajc72 in forum Excel General
    Replies: 1
    Last Post: 09-02-2011, 07:02 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