Quantcast
Channel: Hot Weekly Questions - Web Applications Stack Exchange
Viewing all articles
Browse latest Browse all 9782

How to extract date and time in Google Sheets [closed]

$
0
0

I'm trying to extract the time and date from column A.

In cell A1 for example is written: October 25, 2023 at 07:23PM

In cell A2 for example is written: October 26, 2023 at 01:01AM

I'm trying to extract the date and time as a formatted 'time / date' value, so that I can calculate the time difference between the two. Note, that the time needs to be formatted in a 24-hour format.

The formula I've tried is this here:

=TEXT(TIME(VALUE(REGEXEXTRACT(A1; "\d{1,2}"); VALUE(REGEXEXTRACT(A1; "(\d{2}:\d{2})([AP]M)")) + IF(REGEXMATCH(A1; "PM"); 12; 0)); "HH:mm")

I've also tried already just to extract just the time from it. But it displays then the time wrongly, as 06:28PM is not equal to 06:28 (which would be AM in a 24-hour time format)

=value(regexextract(A1; "\d{1,1}:\d{2}"))


Viewing all articles
Browse latest Browse all 9782

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>