I have nearly 2,00,000 records of data in my excel sheet and I have Date columns as a string like this (dd.mm.yy) I have to convert it into dateformat of (YYYY-MM-DD) .
I tried this -
For the example date string, 1.11.11 , I tried to replace .11 with .2011 but it will also change the month to 1.2011.2011 and my sheet has huge records from 2010 to 2016 .
Example - My cell has this 1.11.11 and i want to convert it to 2011-01-01 (YYYY-MM-DD)
Please help ! Thank you.
Use this to change it to a true date:
=DATE(2000+SUBSTITUTE(RIGHT(A1,2),".",""),SUBSTITUTE(MID(A1,FIND(".",A1)+1,2),".",""),SUBSTITUTE(LEFT(A1,2),".",""))
Then format the output to your desired: YYYY-MM-DD
To do it in place one would need vba.
Select your date cells and run this code.
Sub datechange()
Dim rng As Range
Dim str() As String
For Each rng In Selection
str = Split(rng.Value, ".")
rng.Value = DateSerial(2000 + str(2), str(1), str(0))
Next rng
Selection.NumberFormat = "yyyy-mm-dd"
End Sub
假设这些值以A1开头,并且所有值都真正位于DD.MM.YY中(带有零(04、06等)。
="20"&RIGHT(A1,2)&"-"&MID(A1,4,1)&"-"&LEFT(A1,2)
尝试下面的公式:
=TEXT(SUBSTITUTE(A1,".","/"),"YYYY-MM-DD")
尝试这个:
select convert(varchar,convert(datetime,'26-July-2018'),105)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.