Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 15
Default Date String To Serial

Hi all,

Is there a way to convert this date string

OCT 23'08 6:04PM

into serial that Excel will recognize as a number instead of a string?

Thanks!
goss
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 37
Default Date String To Serial

In Excel, if only the dates are netred then the dates are actually stored as
numbers (integers) and when you add time to date then that numbers become
decimal numbers.

Actually, if you change the format of the cell to numbers without decimals
you will get the result.

--
Kind Regards,
Satti Charvak
Only an Excel Enthusiast
Noida, India


"goss" wrote:

Hi all,

Is there a way to convert this date string

OCT 23'08 6:04PM

into serial that Excel will recognize as a number instead of a string?

Thanks!
goss

  #3   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 11,058
Default Date String To Serial

Assuming that the data is in Text format, in a work area, say E1 tru F12
enter this table:

JAN 1
FEB 2
MAR 3
APR 4
MAY 5
JUN 6
JUL 7
AUG 8
SEP 9
OCT 10
NOV 11
DEC 12

Then with your value in A1:

=DATE(2000+MID(A1,8,2),VLOOKUP(LEFT(A1,3),E1:F12,2 ,FALSE),MID(A1,5,2))

--
Gary''s Student - gsnu200812


"goss" wrote:

Hi all,

Is there a way to convert this date string

OCT 23'08 6:04PM

into serial that Excel will recognize as a number instead of a string?

Thanks!
goss

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 2,389
Default Date String To Serial

You can use Text to Columns.
Specify a fixed width for two columns, one for the date, and one for the
time.

You can discard the time, if you want, by skipping the column.

Regards,
Fred.

"goss" wrote in message
...
Hi all,

Is there a way to convert this date string

OCT 23'08 6:04PM

into serial that Excel will recognize as a number instead of a string?

Thanks!
goss


  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,651
Default Date String To Serial

On Fri, 7 Nov 2008 03:18:42 -0800 (PST), goss wrote:

Hi all,

Is there a way to convert this date string

OCT 23'08 6:04PM

into serial that Excel will recognize as a number instead of a string?

Thanks!
goss


If all of your dates will be in this century, then:

and if the format will always be:

mmm dd\'yy h:mmAM/PM

=--REPLACE(REPLACE(A1,LEN(A1)-1,," "),7,1,", 20")

If the format of the string may be different, then post back with more details.
--ron


  #6   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 15
Default Date String To Serial

On Nov 7, 5:43*am, Ron Rosenfeld wrote:
On Fri, 7 Nov 2008 03:18:42 -0800 (PST), goss wrote:
Hi all,


Is there a way to convert this date string


OCT 23'08 6:04PM


into serial that Excel will recognize as a number instead of a string?


Thanks!
goss


If all of your dates will be in this century, then:

and if the format will always be:

mmm dd\'yy h:mmAM/PM

=--REPLACE(REPLACE(A1,LEN(A1)-1,," "),7,1,", 20")

If the format of the string may be different, then post back with more details.
--ron


Thanks all!

Ron,

Works great!
Yes, The String is extracted from a UNIX report and will always be
same format
But instead of adding a helper column can I use For Next Loop to go
through the range and use approximately the same function?
I tried but received

"Compile error:
Argument not optional"

Here is my code snippet

'Replace
For Each C In myRange
C.Value = C.Replace(Replace(C.Value, Len(C.Value) - 1, , " "),
7, 1, ", 20")
Next C

Thanks!
goss

  #7   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,651
Default Date String To Serial

On Fri, 7 Nov 2008 06:34:19 -0800 (PST), goss wrote:

On Nov 7, 5:43*am, Ron Rosenfeld wrote:
On Fri, 7 Nov 2008 03:18:42 -0800 (PST), goss wrote:
Hi all,


Is there a way to convert this date string


OCT 23'08 6:04PM


into serial that Excel will recognize as a number instead of a string?


Thanks!
goss


If all of your dates will be in this century, then:

and if the format will always be:

mmm dd\'yy h:mmAM/PM

=--REPLACE(REPLACE(A1,LEN(A1)-1,," "),7,1,", 20")

If the format of the string may be different, then post back with more details.
--ron


Thanks all!

Ron,

Works great!
Yes, The String is extracted from a UNIX report and will always be
same format
But instead of adding a helper column can I use For Next Loop to go
through the range and use approximately the same function?
I tried but received

"Compile error:
Argument not optional"

Here is my code snippet

'Replace
For Each C In myRange
C.Value = C.Replace(Replace(C.Value, Len(C.Value) - 1, , " "),
7, 1, ", 20")
Next C

Thanks!
goss


Yes you can, but VBA is a bit "smarter", so you could use something like:

For Each c In MyRange
s = Replace(c.Value, "'", ", 20")
c.Value = DateValue(s) + TimeValue(s)
c.NumberFormat = "mmm dd, yyyy h:mm am/pm"
Next c
--ron
  #8   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 15
Default Date String To Serial

On Nov 7, 11:52*am, Ron Rosenfeld wrote:
On Fri, 7 Nov 2008 06:34:19 -0800 (PST), goss wrote:
On Nov 7, 5:43*am, Ron Rosenfeld wrote:
On Fri, 7 Nov 2008 03:18:42 -0800 (PST), goss wrote:
Hi all,


Is there a way to convert this date string


OCT 23'08 6:04PM


into serial that Excel will recognize as a number instead of a string?


Thanks!
goss


If all of your dates will be in this century, then:


and if the format will always be:


mmm dd\'yy h:mmAM/PM


=--REPLACE(REPLACE(A1,LEN(A1)-1,," "),7,1,", 20")


If the format of the string may be different, then post back with more details.
--ron


Thanks all!


Ron,


Works great!
Yes, The String is extracted from a UNIX report and will always be
same format
But instead of adding a helper column can I use For Next Loop to go
through the range and use approximately the same function?
I tried but received


"Compile error:
Argument not optional"


Here is my code snippet


* *'Replace
* *For Each C In myRange
* * * *C.Value = C.Replace(Replace(C.Value, Len(C.Value) - 1, , " "),
7, 1, ", 20")
* *Next C


Thanks!
goss


Yes you can, but VBA is a bit "smarter", so you could use something like:

For Each c In MyRange
* * s = Replace(c.Value, "'", ", 20")
* * c.Value = DateValue(s) + TimeValue(s)
* * c.NumberFormat = "mmm dd, yyyy h:mm am/pm"
Next c
--ron- Hide quoted text -

- Show quoted text -


Thanks Ron,

Option Explicit is on

I was not sure of data type for s?
I tried S as string and long
Neither worked

I receive A Typ Mismatch Error Message

Thanks!
goss
  #9   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,651
Default Date String To Serial

On Fri, 7 Nov 2008 12:38:44 -0800 (PST), goss wrote:

Thanks Ron,

Option Explicit is on

I was not sure of data type for s?
I tried S as string and long
Neither worked

I receive A Typ Mismatch Error Message

Thanks!
goss


s is String.

As in:

======================
Option Explicit
Sub foo()
Dim s As String
Dim MyRange As Range, c As Range

Set MyRange = Range("a1") 'obviously should be changed.

For Each c In MyRange
s = Replace(c.Value, "'", ", 20")
c.Value = DateValue(s) + TimeValue(s)
c.NumberFormat = "mmm dd, yyyy h:mm am/pm"
Next c
End Sub
=======================
--ron
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
serial value to date in excel [email protected] Excel Worksheet Functions 0 August 12th 08 07:46 PM
Serial Numbers converted to text string JGG Excel Worksheet Functions 3 September 15th 06 05:59 PM
Serial number of Date Gazzr Excel Worksheet Functions 2 March 24th 06 08:59 AM
date displays as serial number et Excel Discussion (Misc queries) 2 April 19th 05 01:10 AM
How do I convert Date serial number to date rdunne Excel Worksheet Functions 1 April 12th 05 03:04 PM


All times are GMT +1. The time now is 05:34 PM.

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"