Showing a timestamp from a datetimestamp as either AM or PM - date

I have a number of date/time entries in a spreadsheet which I wish to reformat as follows
10/20/2014 13:00:00 (mm/dd/yyyy hh:mm:ss) to show as 20/10/2014 PM
10/01/2014 08:00:00 (mm/dd/yyyy hh:mm:ss) to show as 01/10/2014 AM
I can convert and split the date out easily enough but I cannot get the hh:mm:ss to show as simply AM or PM.
Thanks

Under Format Cells, choose the Number tab, select Custom, and enter this format:
dd/mm/yyyy AM/PM
You can also do this using the TEXT function:
=TEXT(Date,"dd/mm/yyyy AM/PM")

Related

Convert a dates from Tweet hydrator to standard date format in Google Sheets mm/dd/yyyy

I have a large dataset (close to 80,000) of tweets dated like this:
Wed Oct 05 01:20:53 +0000 2016
What script can I run to convert the dates in Google Sheets to the simple mm/dd/yyyy form?
In this case, it should be: 10/05/2016
Thanks!
If the format of the date is you mentioned is consistent, you can use the below formula (assuming the date is in cell A1)
=DATEVALUE(RIGHT(A1,4) & MID(A1,5,3) & MID(A1,9,2))
This will extract the Datevalue from the string and then you can format it to look in the mm/dd/yyyy format
Try
=arrayformula(if(A1:A="",,1*(regexextract(A1,"\d{2}")&"/"&regexextract(A1,"\D+ (\D+) ")&"/"&regexextract(A1,".* (\d+)"))))
or (with hours/minutes/seconds)
=arrayformula(if(A1:A="",,1*(regexextract(A1,"\d{2}")&"/"&regexextract(A1,"\D+ (\D+) ")&"/"&regexextract(A1,".* (\d+)"))+regexextract(A1,"\d{2}:\d{2}:\d{2}")))
and define the appropriate format
Another solution
=index(ifna(Text(1&RegexExtract(A:A,".*?\s(.*?)\s"),"MM")&"/"&RegexExtract(A:A,"\d{2}")&"/"&RegexExtract(A:A,".*\s(.*)")))
Or
=index(text(regexreplace(regexreplace(A:A,"\+0000\s",),"(.*)(\d+:\d+:\d+)\s(.*)","$1$3 $2"),"mm/dd/yyyy"))
Or
=index(text(regexreplace(A:A,"(.*\s)(\d+:.*)\+.*\s(.*)","$1$3 $2"),"mm/dd/yyyy"))

Convert MMM DD, YYYY with timestamp to MM/DD/YYYY in Google Sheets

I have a Google Sheet with dates in this format: Jul 20, 2021, 1:57:53 PM
Unfortunately, Google Sheets doesn't recognize this string to convert the date automatically to MM/DD/YYYY. What formula can I use to quickly convert 2000+ dates to MM/DD/YYYY format?
Here is a sample of some of the data I would like to convert and the type of result I'm looking for: https://docs.google.com/spreadsheets/d/1UcHNOtsMUNOvPcIYVXYRefFfNE6eLXavxFKk6Pp7sus/edit#gid=0
Thank you!
try:
=INDEX(IFNA(TEXT(REGEXEXTRACT(A2:A, "(.+),"), "mm/dd/yyyy")))
or if you need datevalue:
=INDEX(IFNA(VALUE(REGEXEXTRACT(A2:A, "(.+),"))))

How to convert a string date format `October 18th 2019` into a valid date `2019-10-17T23:00:00.000Z`

I need to convert a string date format like this October 18th 2019 ('MMMM Do YYYY') into a valid date 2019-10-17T23:00:00.000Z or similar 17/10/2019
i have tried using parsing the string into moment but i keep getting errors
update: I used moment('October 18th 2019').format(). received invalid date as the error, sorry I should clarify i'm trying to convert the string October 18th 2019 into a valid date format,
You simply need to supply the format string for the input (MMMM Do YYYY) when constructing the Moment object, with one of the following approaches:
// this way interprets the input at the start of the day in the local time zone
moment('October 18th 2019', 'MMMM Do YYYY')
// this way interprets the input at the start of the day in UTC
moment.utc('October 18th 2019', 'MMMM Do YYYY')
// this way interprets the input at the start of the day in a specific named time zone
// (requires the moment-timezone add-on)
moment.tz('October 18th 2019', 'MMMM Do YYYY', 'Europe/London')
Then you can format and/or convert it however desired. For example:
// this way keeps the local time, includes the local time offset when formatting
moment('October 18th 2019', 'MMMM Do YYYY').format()
// this way converts from local to utc before formatting
moment('October 18th 2019', 'MMMM Do YYYY').utc().format()
// this way converts from local to utc before formatting and includes milliseconds
moment('October 18th 2019', 'MMMM Do YYYY').toISOString()

Converting String to Date using T-map with Talend Open Studio

I'm having trouble converting a couple of sting fields to date with Talend Open Studio. All date fields are coming to me via csv in the format "MM/dd/yyyy hh:mm:ss aa" For example "03/20/2018 2:40:03 PM"
Many date fields are fine, and conversion with the t-map component and the talend.date (parse date) is working as it should. The problem occurs in two fields where many almost all of the dates are coming in as "12/30/1899 00:00:00 AM"
I'm using the tmap to push the file to a toutputdelimited (CSV). The format of the fields with "12/30/1899 00:00:00 AM" is coming back as "#######################." Any ideas on how to handle the situation would be great. The output date format is "yyyy-MM-dd HH:mm:ss"
Again, all other fields are converting as they should. Its only the special case "12/30/1899 00:00:00 AM" that is causing problems.
Thans!
Since your dates can be of different formats, you need to read your column as a String type in your tFileInputDelimited, then inside a tMap, check the date type (a simple way to check it is by testing its length) and parse it using the correct date format:
tFileInputDelimited -- tMap -- output
In a tMap expression, you can have something like this :
row.created_ts.length() == 22 ? TalendDate.parseDate("yyyy-MM-dd hh:mm:ssX", row.yourdate) : TalendDate.parseDate("yyyy-MM-dd hh:mm:ss.SSSSSSX", row.yourdate)

Unparseable Date error - Talend

I am trying to copy data from Excel to a SQL table.
I have dates generated in Excel file using RAND function. I am taking them as strings in an input and trying to convert them in date data type using tConvertType.
I have setted its datatype as 'string' in initial input and as 'date' in tConvertType's output and in tMSSqlOutput.
My job has work flow Excel input -> tConvertType -> tMap -> tMSSqlOutput.
While running the job I am getting an error which says :
java.text.ParseException: Unparseable date: "Tue Jul 17 00:00:00 EDT 1973"
I am not sure where the problem lies.
If anyone could help me with this it would be much appreciated.
Here's the screenshot of my job.
i am able to parse your given sample date please use below function in tMap for your date filed.
System.out.println(TalendDate.parseDateLocale("EEE MMM dd HH:mm:ss zzz yyyy", 'Tue Jul 17 00:00:00 EDT 1973', "EN"));
function is yourDateColumn!=null && !"".equalsIgnoreCase(yourDateColumn)? TalendDate.parseDateLocale("EEE MMM dd HH:mm:ss zzz yyyy", yourDateColumn, "EN") :null
#UmeshR: your code is working fine, but you have to handle the timezone thing as well. e.g. I am from India and when i converted the time from EDT talend converted it to my local timezone. see the screen-shot.