Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default A VBA function to give serial date for date and time?

Is there a VBA function which would convert a date into a serial number,
without you having to feed it the Year, Month, Day and time data as
individual values?

Had no luck finding it. Would make date & comparison so much easier.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 45
Default A VBA function to give serial date for date and time?

Assuming you mean your date is text (a string), use the CDate or DateValue
function.

DateValue won't include the time component, CDate will.

On Wed, 7 Jul 2004 17:08:56 -0400, "Android" wrote:

Is there a VBA function which would convert a date into a serial number,
without you having to feed it the Year, Month, Day and time data as
individual values?

Had no luck finding it. Would make date & comparison so much easier.


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,253
Default A VBA function to give serial date for date and time?

dim dt as date
dt=dateserial(2004,4,3) (y,m,d)
dt=datevalue("3 sep 2004")

'note the string will evaluate using a 'locale' so might not work for all
users... e.g. datevalue("3 okt 2004") would work for me in Holland :)


keepITcool

< email : keepitcool chello nl (with @ and .)
< homepage: http://members.chello.nl/keepitcool


"Android" wrote:

Is there a VBA function which would convert a date into a serial number,
without you having to feed it the Year, Month, Day and time data as
individual values?

Had no luck finding it. Would make date & comparison so much easier.




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default A VBA function to give serial date for date and time?

The date is a "Date" , and not a string. I was aware of DateValue, but as
you say, that requires a string to be fed to it.


"Myrna Larson" wrote in message
...
Assuming you mean your date is text (a string), use the CDate or DateValue
function.

DateValue won't include the time component, CDate will.

On Wed, 7 Jul 2004 17:08:56 -0400, "Android"

wrote:

Is there a VBA function which would convert a date into a serial number,
without you having to feed it the Year, Month, Day and time data as
individual values?

Had no luck finding it. Would make date & comparison so much easier.




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default A VBA function to give serial date for date and time?

On Thu, 8 Jul 2004 08:56:21 -0400, "Android" wrote:

The date is a "Date" , and not a string. I was aware of DateValue, but as
you say, that requires a string to be fed to it.


If the date is a true date, then it "is" a serial number.

So to express it you could use something like CDbl(dt)


For example, with a Date in Selection, this SUB will express the serial number:

Sub dtser()
MsgBox (CDbl(Selection.Value))
End Sub


--ron


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default A VBA function to give serial date for date and time?

Thank you. This really clarifies it for me.

Android.
"Ron Rosenfeld" wrote in message
...
On Thu, 8 Jul 2004 08:56:21 -0400, "Android"

wrote:

The date is a "Date" , and not a string. I was aware of DateValue, but as
you say, that requires a string to be fed to it.


If the date is a true date, then it "is" a serial number.

So to express it you could use something like CDbl(dt)


For example, with a Date in Selection, this SUB will express the serial

number:

Sub dtser()
MsgBox (CDbl(Selection.Value))
End Sub


--ron



  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,651
Default A VBA function to give serial date for date and time?

On Thu, 8 Jul 2004 10:50:30 -0400, "Android" wrote:

Thank you. This really clarifies it for me.

Android.


You're welcome.


--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
Converting date/time serial values to cumulative time totals... Kevin B Excel Discussion (Misc queries) 4 October 18th 07 05:05 PM
Formula to give date and time Angela1979 Excel Worksheet Functions 6 April 13th 07 02:36 AM
How Do I Eliminate the Serial Number for time from Date? Bob Gotti Excel Discussion (Misc queries) 2 January 19th 06 05:24 PM
Format serial date and time Cedric Excel Discussion (Misc queries) 2 December 26th 05 09:06 PM
extract time from excel serial date Dan W[_2_] Excel Programming 4 June 8th 04 06:52 PM


All times are GMT +1. The time now is 11:56 AM.

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

About Us

"It's about Microsoft Excel"