Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
cj cj is offline
external usenet poster
 
Posts: 1
Default Date & Time programming

Can someone please help? I have some time/date data that
I bring over to Excel from Access that is formatted like
this: 8/30/2004 6:36. What I am trying to accomplish is
to give me the total number of calls say between 6:30 am
and 7:30 am, 7:31 am through 8:30, etc. The problem is
that if I try to extract the time, it gives me weird
numbers (when I format it for numbers, it gives me
38229.27523, which I am assuming is the number value for
Excel for this date). I know how to do VLOOKUPS, but I
can't get it to work because the date/time is not
formatted right. I have tried to format it every way,
but it still doesn't work. Any advice? Thanks!


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default Date & Time programming

Hi cj,
In Excel, one day is 1 unit, so in 38229.27523 the 38229 is trhe date and
0.27523 is the fraction of the day (the time: 1/24 is an hour , 1/(24*60) is
a minute...).

Now, say A1:A35 contains your date/time. Say you want to count hgow many
rows within 2 date/time value entered in A38 and A39:
If A38, A39 are date/time data type, in A40, enter:
=SUMPRODUCT((A1:A35A38)*(A1:A35<A39)*1)
If A38, A39 are strings representing a date:
=SUMPRODUCT((A1:A35VALUE(A38))*(A1:A35<VALUE(A39) )*1)
(here the string is converted to a date/time using the VALUE() function)

In VBA, you can use the Evaluate function:
Application.Evaluate("=SUMPRODUCT((A1:A35A38)*(A1 :A35<A39)*1)")

In vba, with parameters from vba, something like:
Sub test()
Dim strDate1 As String, strDate2 As String
Dim date1 As Date, date2 As Date
Dim v

strDate1 = "9/9/2004 12:01:50 PM"
strDate2 = "9/9/2004 12:09:02 PM"

date1 = strDate1
date2 = strDate2

v = Application.Evaluate("=SUMPRODUCT((A1:A35" & CDbl(date1) &
")*(A1:A35<" & CDbl(date2) & ")*1)")
MsgBox v
End Sub

I hope this helps,
Sebastien
"cj" wrote:

Can someone please help? I have some time/date data that
I bring over to Excel from Access that is formatted like
this: 8/30/2004 6:36. What I am trying to accomplish is
to give me the total number of calls say between 6:30 am
and 7:30 am, 7:31 am through 8:30, etc. The problem is
that if I try to extract the time, it gives me weird
numbers (when I format it for numbers, it gives me
38229.27523, which I am assuming is the number value for
Excel for this date). I know how to do VLOOKUPS, but I
can't get it to work because the date/time is not
formatted right. I have tried to format it every way,
but it still doesn't work. Any advice? Thanks!



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
Formula causing run-time error in Excel Programming cherman Excel Worksheet Functions 2 March 15th 10 10:59 PM
Date programming MeMe Excel Worksheet Functions 2 January 16th 06 06:50 PM
Calculating days & time left from start date/time to end date/time marie Excel Worksheet Functions 7 December 7th 05 02:36 PM
programming date functions Gail Excel Worksheet Functions 2 November 22nd 05 06:32 PM
Date Programming Dan E[_2_] Excel Programming 0 October 8th 03 05:59 PM


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