Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Get long value for a date string

I have a date string of 2/21/2005 1:07:22 PM. When I convert it to Long I
get a value of 38405, which is 2/22/2005. How can I make the value be
2/21/2005? Can I truncate the date string to remove the time part?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3,290
Default Get long value for a date string

jerry,

Use a Double instead of a Long.

Regards,
Jim Cone
San Francisco, USA

"jerry chapman" wrote in message
om...
I have a date string of 2/21/2005 1:07:22 PM. When I convert it to Long I
get a value of 38405, which is 2/22/2005. How can I make the value be
2/21/2005? Can I truncate the date string to remove the time part?


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Get long value for a date string

sStr = "2/21/2005 1:07:22 PM"
v = int(cdate(sStr))
? v
02/21/2005

you could
dim v as Long

--
Regards,
Tom Ogilvy

"jerry chapman" wrote in message
om...
I have a date string of 2/21/2005 1:07:22 PM. When I convert it to Long I
get a value of 38405, which is 2/22/2005. How can I make the value be
2/21/2005? Can I truncate the date string to remove the time part?




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 17
Default Get long value for a date string

How can I define a cell as date & time?
"Tom Ogilvy" wrote in message
...
sStr = "2/21/2005 1:07:22 PM"
v = int(cdate(sStr))
? v
02/21/2005

you could
dim v as Long

--
Regards,
Tom Ogilvy

"jerry chapman" wrote in message
om...
I have a date string of 2/21/2005 1:07:22 PM. When I convert it to Long

I
get a value of 38405, which is 2/22/2005. How can I make the value be
2/21/2005? Can I truncate the date string to remove the time part?






  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Get long value for a date string

activecell.numberformat = "mm/dd/yyyy hh:mm:ss"

or put a date value in it

Sub CCC()
Dim dt As Date

dt = DateSerial(2005, 2, 21) + TimeSerial(10, 30, 0)
ActiveCell.Value = dt
ActiveCell.EntireColumn.AutoFit
End Sub


--
Regards,
Tom Ogilvy

"jerry chapman" wrote in message
om...
How can I define a cell as date & time?
"Tom Ogilvy" wrote in message
...
sStr = "2/21/2005 1:07:22 PM"
v = int(cdate(sStr))
? v
02/21/2005

you could
dim v as Long

--
Regards,
Tom Ogilvy

"jerry chapman" wrote in message
om...
I have a date string of 2/21/2005 1:07:22 PM. When I convert it to

Long
I
get a value of 38405, which is 2/22/2005. How can I make the value be
2/21/2005? Can I truncate the date string to remove the time part?








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
Long Date - Long Date = text is days tom Excel Discussion (Misc queries) 2 November 13th 06 04:17 AM
search for date in long string of text ryan00davis Excel Discussion (Misc queries) 4 August 11th 06 07:06 PM
Long string of IF formulas changetires Excel Discussion (Misc queries) 3 June 21st 06 08:59 PM
Transposing a Long String carl Excel Worksheet Functions 2 January 3rd 05 02:55 PM
converting a string to long Ciar?n Excel Programming 1 October 28th 04 12:36 PM


All times are GMT +1. The time now is 06:04 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"