Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Converting date/time serial values to cumulative time totals... | Excel Discussion (Misc queries) | |||
Formula to give date and time | Excel Worksheet Functions | |||
How Do I Eliminate the Serial Number for time from Date? | Excel Discussion (Misc queries) | |||
Format serial date and time | Excel Discussion (Misc queries) | |||
extract time from excel serial date | Excel Programming |