Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
ryan
 
Posts: n/a
Default Text to date then subtract...

Hello all,

Time to ask the experts, I'm completly lost!

I've got two text fields that are actually dates & times:
A1 = 20030715085639
B1 = 20030715085707

I need the difference in seconds between the two ... in this example 28.
  #2   Report Post  
Posted to microsoft.public.excel.misc
Dave O
 
Posts: n/a
Default Text to date then subtract...

Format your answer cell as time, showing hours, minutes and seconds
(the custom format looks like h:mm:ss;@). Then enter this formula:
=(DATE(MID(B1,1,4),MID(B1,5,2),MID(B1,7,2))+TIME(M ID(B1,9,2),MID(B1,11,2),MID(B1,13,2)))-(DATE(MID(A1,1,4),MID(A1,5,2),MID(A1,7,2))+TIME(MI D(A1,9,2),MID(A1,11,2),MID(A1,13,2)))

This formula parses the date/time stamp string into date and time
formats recognized by Excel, then subtracts the start from the finish.

  #3   Report Post  
Posted to microsoft.public.excel.misc
Roger Govier
 
Posts: n/a
Default Text to date then subtract...

Hi Ryan

In cell A2
=("00:"&MID(A1,11,2)&":"&RIGHT(A1,2))+0
Copy to cell B2
In cell C2
=B2-A2

Regards

Roger Govier


ryan wrote:
Hello all,

Time to ask the experts, I'm completly lost!

I've got two text fields that are actually dates & times:
A1 = 20030715085639
B1 = 20030715085707

I need the difference in seconds between the two ... in this example 28.

  #4   Report Post  
Posted to microsoft.public.excel.misc
ryan
 
Posts: n/a
Default Text to date then subtract...

Dave, you rock! Thanks very much! Perfect!

"Dave O" wrote:

Format your answer cell as time, showing hours, minutes and seconds
(the custom format looks like h:mm:ss;@). Then enter this formula:
=(DATE(MID(B1,1,4),MID(B1,5,2),MID(B1,7,2))+TIME(M ID(B1,9,2),MID(B1,11,2),MID(B1,13,2)))-(DATE(MID(A1,1,4),MID(A1,5,2),MID(A1,7,2))+TIME(MI D(A1,9,2),MID(A1,11,2),MID(A1,13,2)))

This formula parses the date/time stamp string into date and time
formats recognized by Excel, then subtracts the start from the finish.


  #5   Report Post  
Posted to microsoft.public.excel.misc
Ron Rosenfeld
 
Posts: n/a
Default Text to date then subtract...

On Wed, 7 Dec 2005 07:31:02 -0800, "ryan"
wrote:

Hello all,

Time to ask the experts, I'm completly lost!

I've got two text fields that are actually dates & times:
A1 = 20030715085639
B1 = 20030715085707

I need the difference in seconds between the two ... in this example 28.


At least in the US:

=ROUND((TEXT(B1,"0000\/00\/00 00\:00\:00")-
TEXT(A1,"0000\/00\/00 00\:00\:00"))*24*60*60,0)


--ron


  #6   Report Post  
Posted to microsoft.public.excel.misc
Sloth
 
Posts: n/a
Default Text to date then subtract...

Yet another answer. Use this formula (same end result as Dave O's formula; a
number excel can interpret as date and time)
=VALUE(TEXT(B1,"####-##-## ##\:##\:##"))-VALUE(TEXT(A1,"####-##-##
##\:##\:##"))
and format the cell as
[s]
to show only seconds.

"ryan" wrote:

Hello all,

Time to ask the experts, I'm completly lost!

I've got two text fields that are actually dates & times:
A1 = 20030715085639
B1 = 20030715085707

I need the difference in seconds between the two ... in this example 28.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert Text to DATE Dimmer Excel Discussion (Misc queries) 8 January 22nd 09 01:15 PM
converting text in cell to a date time Herman Excel Worksheet Functions 3 October 22nd 05 07:18 PM
Subtract text in one cell from another? BigIan Excel Worksheet Functions 3 July 7th 05 09:21 AM
Macro to convert text to date Nortos Excel Worksheet Functions 2 May 11th 05 10:42 AM
EXTRACT TEXT FROM A DATE Ronbo Excel Worksheet Functions 5 February 1st 05 07:39 AM


All times are GMT +1. The time now is 03:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"