SOLVED

My date format does not apply to every cell

%3CLINGO-SUB%20id%3D%22lingo-sub-1748453%22%20slang%3D%22en-US%22%3EMy%20date%20format%20does%20not%20apply%20to%20every%20cell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1748453%22%20slang%3D%22en-US%22%3E%3CP%3EHello%20guys%2C%26nbsp%3B%3C%2FP%3E%3CP%3EI%20retrieve%20a%20data%20file%20(excel)%20from%20a%20web%20platform.%20I%20want%20to%20modify%20the%20date%26amp%3Btime%20format%20from%26nbsp%3B%3C%2FP%3E%3CTABLE%20width%3D%22147%22%3E%3CTBODY%3E%3CTR%3E%3CTD%20width%3D%22147%22%3E10%2F1%2F2020%207%3A57%3A00%20AM%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3Eto%3C%2FP%3E%3CTABLE%20width%3D%22147%22%3E%3CTBODY%3E%3CTR%3E%3CTD%20width%3D%22147%22%3E10%2F01%2F2020%2007%3A57%3C%2FTD%3E%3C%2FTR%3E%3C%2FTBODY%3E%3C%2FTABLE%3E%3CP%3Eand%20show%20it%20in%20a%20new%20sheet.%3C%2FP%3E%3CP%3EI%20applied%20this%20formula%20to%20the%20raw%20data%26nbsp%3B%3C%2FP%3E%3CP%3E%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-left%22%20image-alt%3D%22Capture.PNG%22%20style%3D%22width%3A%20492px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F224361i5F62EC9EB47D09AB%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22Capture.PNG%22%20alt%3D%22Capture.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E%26nbsp%3BThe%20formula%20is%20working%20well%20until%20a%20certain%20date%20where%20the%20format%20just%20don't%20want%20to%20change%20anymore.%26nbsp%3B%3CSPAN%20class%3D%22lia-inline-image-display-wrapper%20lia-image-align-inline%22%20image-alt%3D%22Capture2.PNG%22%20style%3D%22width%3A%20352px%3B%22%3E%3CIMG%20src%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fimage%2Fserverpage%2Fimage-id%2F224362iADEA6C8DD92F8A3C%2Fimage-size%2Flarge%3Fv%3D1.0%26amp%3Bpx%3D999%22%20title%3D%22Capture2.PNG%22%20alt%3D%22Capture2.PNG%22%20%2F%3E%3C%2FSPAN%3E%3C%2FP%3E%3CP%3EDoes%20anyone%20had%20the%20same%20issue%20%3F%20How%20can%20I%20fix%20it%20%3F%3C%2FP%3E%3CP%3EThanks%20for%20your%20help%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1748453%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EFormulas%20and%20Functions%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1748634%22%20slang%3D%22en-US%22%3ERe%3A%20My%20date%20format%20does%20not%20apply%20to%20every%20cell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1748634%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F821615%22%20target%3D%22_blank%22%3E%40user_28CB%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%0A%3CP%3EThe%20dates%20are%20in%20USA%20format%20m%2Fd%2Fyyyy%20(m%2Fj%2Faaaa%20in%20French).%209%2F30%2F2020%20is%20not%20recognized%20as%20a%20valid%20date%20by%20your%20system.%3C%2FP%3E%0A%3CP%3ETry%20this%20macro%3A%3C%2FP%3E%0A%3CPRE%20class%3D%22lia-code-sample%20language-visual%22%3E%3CCODE%3ESub%20ConvertDates()%0A%20%20%20%20Dim%20rng%20As%20Range%0A%20%20%20%20Application.ScreenUpdating%20%3D%20False%0A%20%20%20%20For%20Each%20rng%20In%20Range(Range(%22A2%22)%2C%20Range(%22A%22%20%26amp%3B%20Rows.Count).End(xlUp))%0A%20%20%20%20%20%20%20%20rng.Offset(0%2C%201).Value%20%3D%20CDate(rng.Value)%0A%20%20%20%20Next%20rng%0A%20%20%20%20Application.ScreenUpdating%20%3D%20True%0AEnd%20Sub%3C%2FCODE%3E%3C%2FPRE%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1748675%22%20slang%3D%22en-US%22%3ERe%3A%20My%20date%20format%20does%20not%20apply%20to%20every%20cell%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1748675%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F821615%22%20target%3D%22_blank%22%3E%40user_28CB%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CP%3EHi.%20if%20you%20look%20at%20your%20A-column%20it's%20Aligned%20to%20the%20left%20and%20probably%20a%20text.%20You%20have%20to%20change%20it%20to%20Excels%20date-format%20before%20you%20change%20it%20back%20to%20text%20in%20the%20format%20you%20wish.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EIt%20looks%20as%20if%20the%20data%20is%20in%20American%20date%20format%20with%20the%20%3CSTRONG%3Emonth%20first%3C%2FSTRONG%3E.%3C%2FP%3E%3CP%3EIf%20your%20Computer%20uses%20some%20kind%20of%20logical%20based%20date-system%20the%20conversion%20might%20get%20messy.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3E2%20solutions%20that%20might%20work%3C%2FP%3E%3CP%3E1.)%3C%2FP%3E%3CP%3ESelect%20column%20A.%20goto%3C%2FP%3E%3CP%3EDATA-%26gt%3Btext%20to%20column-%26gt%3Bnext%2C%20next%3A%20Date%20MDY%26nbsp%3B%20(with%20the%20month%20first.%20Use%20the%20correct%20letters%20in%20your%20language)%3C%2FP%3E%3CP%3EIf%20this%20doesn%E2%80%99t%20work%20(the%20AM%2FPM%20might%20mess%20things%20up)%20you%20could%20try.%3C%2FP%3E%3CP%3E2.)%3C%2FP%3E%3CP%3ESelect%20a%20date-text-cell%20somewhere%20in%20column%20A%3C%2FP%3E%3CP%3EData-%26gt%3BGet%20an%20transform-%26gt%3B%20table%2Finterval%3A%3C%2FP%3E%3CP%3ESince%20the%20source%20data%20is%20USA-formated%20the%20data%20is%20probably%20transformed%20correctly%20(close%20and%20load).%3C%2FP%3E%3CP%3EThis%20gives%20you%20a%20table%20with%20excel-dates%20that%20can%20be%20manipulated%20in%20any%20way%20you%20want%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Visitor

Hello guys, 

I retrieve a data file (excel) from a web platform. I want to modify the date&time format from 

10/1/2020 7:57:00 AM

to

10/01/2020 07:57

and show it in a new sheet.

I applied this formula to the raw data 

Capture.PNG

 

 

 

 

 

 

 

 

 

 The formula is working well until a certain date where the format just don't want to change anymore. Capture2.PNG

Does anyone had the same issue ? How can I fix it ?

Thanks for your help 

2 Replies
Highlighted

@user_28CB 

The dates are in USA format m/d/yyyy (m/j/aaaa in French). 9/30/2020 is not recognized as a valid date by your system.

Try this macro:

Sub ConvertDates()
    Dim rng As Range
    Application.ScreenUpdating = False
    For Each rng In Range(Range("A2"), Range("A" & Rows.Count).End(xlUp))
        rng.Offset(0, 1).Value = CDate(rng.Value)
    Next rng
    Application.ScreenUpdating = True
End Sub
Highlighted
Best Response confirmed by allyreckerman (Microsoft)
Solution

@user_28CB 

Hi. if you look at your A-column it's Aligned to the left and probably a text. You have to change it to Excels date-format before you change it back to text in the format you wish.

 

It looks as if the data is in American date format with the month first.

If your Computer uses some kind of logical based date-system the conversion might get messy.

 

2 solutions that might work

1.)

Select column A. goto

DATA->text to column->next, next: Date MDY  (with the month first. Use the correct letters in your language)

If this doesn’t work (the AM/PM might mess things up) you could try.

2.)

Select a date-text-cell somewhere in column A

Data->Get an transform-> table/interval:

Since the source data is USA-formated the data is probably transformed correctly (close and load).

This gives you a table with excel-dates that can be manipulated in any way you want