The following custom function will transform the string date notation into a date notation:
Code
function myDate(range) {
var output = [];
for(var i=0, iLen=range.length; i<iLen; i++) {
var rSplit = range[i][0].split(" "), corr = 0;
if(rSplit[4].substring(5,7) == "PM") {
corr = 10;
}
var month = parseInt(new Date(Date.parse(rSplit[0]+"1,2013")).getMonth());
var day = parseInt(rSplit[1].replace(/,/g, ""));
var year = parseInt(rSplit[2]);
var hour = parseInt(rSplit[4].substring(0,2))+corr;
var min = parseInt(rSplit[4].substring(3,5),10);
var nDate = new Date(year, month, day, hour, min);
output.push([nDate]);
}
return output;
}
Remark
Correction is made to account for AM/PM
. No correction for GMT
. Add this script via the Tools
menu in the spreadsheet and select Script editor
. Save the script and you are ready to go !!
Usage
myDate(A1:A4)
Example
I've created an example file for you: string date to date
Google Drive
has a built-inScript Editor
(Tools
-Script Editor
) you can use to write a custom script to do what you want. You could post a question onStackOverflow
if you get stuck.