Create database based on 24 hour time; 15 minute increments

Follow
Email
I need to set up a MS Access Database that stores test data that was 
performed at certain times (rounded to the nearest 15 minutes).  

I need to produce a query that shows each 15 minute interval within a 24 
hour period.  Any 15 minute increment that doesn't have test data needs to be 
represented by a -1.  

Any suggestions on how to do this?

0
Reply Utf 2/29/2008 5:35:00 PM
access 16762 articles. 2 followers. Follow

1 Replies
1360 Views

Similar Articles

[PageSpeed] 17
If you first create a table which has one row for every 15 minute interval 
over a suitable period you can then LEFT JOIN this to your table of test 
results to return a row for every time regardless of whether there is test 
data for that time.  As it happens I have a VBA function which will create 
such a table (it was originally written for scheduling appointments).  The 
function uses ADOX as well as ADO do you'll need to create a reference to the 
Microsoft ADO Extensions for DDL and Security library if you don't already 
have one (Tools | References on the VBA menu bar).  Then paste the following 
function into any standard module:

Public Function MakeSchedule(strTable As String, _
                            dtmStart As Date, _
                            dtmEnd As Date, _
                            dtmDayStart As Date, _
                            dtmDayEnd As Date, _
                            intMinuteInterval As Integer, _
                            ParamArray varDays() As Variant)
                            
    ' Accepts:  Name of schedule table to be created: String.
    '           Start date for calendar: DateTime.
    '           End date for calendar: DateTime.
    '           Time when first 'time-slot' starts each day: DateTime
    '           Time when last 'time-slot' starts each day: DateTime
    '           Length of each 'time-slot' in schedule in minutes: Integer
    '           Days of week to be included in calendar
    '           as value list, e,g 2,3,4,5,6 for Mon-Fri
    '           (use 0 to include all days of week)

    Dim cmd As ADODB.Command
    Dim cat As ADOX.Catalog
    Dim tbl As ADOX.Table
    Dim strSQL As String
    Dim dtmDate As Date
    Dim dtmTime As Variant
    Dim varDay As Variant
    
    Set cmd = New ADODB.Command
    cmd.ActiveConnection = CurrentProject.Connection
    cmd.CommandType = adCmdText

    Set cat = New Catalog
    cat.ActiveConnection = CurrentProject.Connection
    
    ' does table exist? If so delete it
    On Error Resume Next
    Set tbl = cat(strTable)
    If Err = 0 Then
        strSQL = "DROP TABLE " & strTable
        cmd.CommandText = strSQL
        cmd.Execute
    End If
    On Error GoTo 0
    
    ' create new table
    strSQL = "CREATE TABLE " & strTable & _
        "(StartTime DATETIME," & _
        "CONSTRAINT PrimaryKey PRIMARY KEY (StartTime))"
    cmd.CommandText = strSQL
    cmd.Execute
    
        ' fill table with dates of selected days of week
        For dtmDate = dtmStart To dtmEnd
            For Each varDay In varDays()
                If Weekday(dtmDate) = varDay Or varDay = 0 Then
                    For dtmTime = dtmDate + dtmDayStart To dtmDate + _
                            dtmDayEnd Step intMinuteInterval / 1440
                        cmd.CommandText = strSQL
                        strSQL = "INSERT INTO " & strTable & "(StartTime) " 
& _
                            "VALUES(#" & Format(dtmTime, "mm/dd/yyyy 
hh:nn:ss") & "#)"
                        cmd.CommandText = strSQL
                        cmd.Execute
                    Next dtmTime
                End If
            Next varDay
        Next dtmDate
   
    Set cmd = Nothing
    
End Function

To create a table called FifteenMinuteSchedule covering from the start of 
this year to the end of 2010 for instance call the function with:

MakeSchedule "FifteenMinuteSchedule", #01/01/2008#, #12/31/2010#, 
#00:00:00#,#23:45:00#, 15, 0

The above will probably have split over two lines in your newsgroup reader 
but should be entered as a single line (in the debug window, aka the 
Immediate pane, for instance – press Ctrl+G to open the window).

Assuming your table of test data is called Tests and has a column 
TestDateTime of date/time data type and a column TestResult a query to return 
rows for a 24 hour period, the start time of which you are prompted for as a 
parameter) would be:

PARAMETERS [Enter start date/time:] DATETIME;
SELECT StartTime, IIF(TestResult IS NULL,-1,TestResult) AS Result
FROM FifteenMinuteSchedule LEFT JOIN Tests
ON FifteenMinuteSchedule.StartTime = Tests.TestDateTime
WHERE StartTime >= [Enter start date/time:] 
AND StartTime < DATEADD("d",1,[Enter start date/time:])
ORDER BY StartTime;

So if you enter 02/28/2008 03:00 (assuming a US short date format is in use) 
you'd get results from 3:00 AM on 28 February 2008 to 2:45 AM on 29 February 
2008.

If you are using the query as the RecordSource for a report omit the ORDER 
BY clause and use the report's own internal sorting mechanism to order the 
rows.

Ken Sheridan
Stafford, England

"DavisGail" wrote:

> I need to set up a MS Access Database that stores test data that was 
> performed at certain times (rounded to the nearest 15 minutes).  
> 
> I need to produce a query that shows each 15 minute interval within a 24 
> hour period.  Any 15 minute increment that doesn't have test data needs to be 
> represented by a -1.  
> 
> Any suggestions on how to do this?
>

0
Reply Utf 2/29/2008 11:27:00 PM
Follow
Email
Reply:
Similar Artilces:

create a roster
How can you create a weekly roster in which functions can be assigned to more than 10 people. The roster should be updatable, so that when holidays and days off are marked on the weekly roster they will be taken account of it future rosters. ...

Converting minutes to seconds #4
I have got this working with excel 2000 but will this work with 97. have tried it but i just get ERR Jame -- smith.james ----------------------------------------------------------------------- smith.james0's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=1623 View this thread: http://www.excelforum.com/showthread.php?threadid=27641 ...

So many Tunnel Adapters
Hi, I understand that Tunnel Adapter LAN is for encapsulating IPv6 packets with an IPv4 header so that they can be sent across an IPv4 network. Few queries popped up in my mind based on this :- 1. Why is the numbering for the Tunnel adapter LAN not sequential ? It is like 6,7,12,13,14,15,16. A strange numbering scheme ?! I tried to figure it out by thinking of some arithmetic series. But, it does not seem to fit in. There is a huge gap between 7 and 12. Any ideas ? 2. What is the need for so many number of Tunnel Adapter LAN connection ? Can you tell me a scenario that re...

User prompted for password 5 times
One of my users is experiencing a very odd (at least to me) behavior. He is logged into his XP system which is joined to our Active Directory, no problems there. When he launches Outlook hs is prompted for his password for some reason. He has to enter his password and click OK, then repeat this step 5 times before it lets him in. Any thoughts? Thanks I'm having a similar problem. Also running XP and Outlook 2003. Did you get any answers? I haven't tried to authenticate 5 times but that should not be the answer! Right? >-----Original Message----- >One of my users is ex...

importing or creating reference footnotes
I am trying to import a word document into publisher and it has reference footnotes within the document. The reference footnotes are not coming into the publisher document with the reference footnotes. Correct, they will not up to Publisher 2003. In Publisher 2003 depending on which version of Word you are using if they will or not. -- "If you don't know where you are going, any road will take you there!" ...

Database Engine Tuning Advisor and autocomplete
Hello there, in the never ending quest for better GP performance, I am onto indexes. I am convinced that there are additional indexes that can improve GP in real life situations, but have been unable to find anyone listing indexes they have used. So my question is, has anyone used the tuning advisor in sql server 05 and implemented its reccomendations? Were there noticable effects on GP performance? While I can run a trace against production and the advisor against a dev environment, I am still wary of implementing the changes in production... On a side question, where are the actu...

Task Create - Status
I'm trying to make a simple task, when a user owner is assigned a task in CRM, it receives an email letting it know it has one. I have the following below, but it is not generating one when i assign one manually in the CRM. What to do? I've tried both the following: When task is created E-Mail to:[owner];Subject test As well as: When task is created if Task activity status = Open then E-Mail to:[owner];Subject test I've checked the mailserver many times over, and I can send emails manually from the CRM so you can rule that out Tested out ok on our end. Some ideas:...

Reference to Knowledge base article 849972
Hi: We are experience this problem very frequently and is creating a problem in our accounting. Some times we are able to enter the invoice and some times not. Please fix this problem as early as possible. Until now in Great Plains 8 service pack 4a this fix is not availabe. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsrea...

using CList as a base class in an extension DLL
Hi all. I must be doing something wrong but cannot figure it out. I have a data class and a list class, in an extension DLL, declared like this: >#define DllExport __declspec (dllexport) >class DllExport CRate : public CObject { >public: > DECLARE_SERIAL (CRate) > CRate () { m_Rate = 0; } > CRate (const CRate &in) { *this = in; } > > const CRate& operator= (const CRate& in) > { m_Rate = in.m_Rate; m_Date = in.m_Date; return *this; } > > bool operator== (const CRate& in); > bool operator!= (const CRate& i...

Mailbox not created when AD account created
A couple of days ago I noticed that I created a user account but the 'Email Addresses' tab of the user properies did not list any email addresses. Subsequent new user accounts have all experienced the same. I researched the knowledge and tried the recommended solutions to either manaully start the recipient update service or rebuild te recipient update service. Neither recommendation has resulted in a mailbox being created for this particular user or any additional user that I have created since this error first showed up. I performed a Windows update last Thursday and so I bel...

Help Creating XmlNode / XmlAttribute Elegantly
I am creating a configuration class to read / write a standard configuration file. <?xml version="1.0" encoding="utf-8"?> <configuration> <appSettings> <add key="ConnectionString" value="server=(local);" /> </appSettings> </configuration> I am using a XmlDocument for my base implementation. I am looking to see if there is a better way to add a new node / attribute than using XmlDocument.InnerXml. I would consider this to be a hack but couldn't really see another way of doing this without definin...

Create external database
Hi all. I need to create an external database (file). On a site I found this code: ------------------------------------------------------ Function CreateLinkedExternalTable(strTargetDB As String, strProviderString As String, strSourceTbl As String, strLinkTblName As String) As String 'strTargetDB = Source Database Name 'strProviderString = Not used, currently hard coded 'strSourceTbl = Source Table name in the database we are linking too. 'strLinkTblName = Table name we would like to see in the Access Database. Dim catDB As ADOX.Catalog Dim tblLink As...

tabls in GP90 database
Does anyone know or have a description or documenation on the tables in the database for GP90? Maybe all I need is the important ones. thanks Within the program itself, Tools > Resource Descriptions Also, there are ERD's on the distribution CD's that you got when you purchased or upgraded the system - you have to install the SDK to get at them. -- Lyle U Adam Clark wrote: > Does anyone know or have a description or documenation on the tables > in the database for GP90? Maybe all I need is the important ones. > > thanks ...

Exchange Database Recovery
Hello, We are a small business with one Exchange 2003 Server. The hard disk died on the server the other day and we couldn't boot. I put in a new disk and reloaded Windows 2003 and Exchange 2003. Thankfully, several of us were using Outlook 2003 with Cached Mode, so we simply backed our email up and reloaded it into the newly restored Exchange. However, one user with several years worth of critical email didn't have Cached Mode turned on for some reason, so I'm trying to restore his email. I was able to connect the damaged hard disk and copy the Exchange database fol...

How to create pie chart with %
I have got a problem that I don't if excel could help me to calculate the % within a column and draw a pie chart. My case is I have a column containing a series of numbers. e.g. 1,4,8,1,3,9,11,2,4,5,6,.........etc I want to draw a pie chart that showing 1-3 , 4-6, 7-9, >9 with the corresponding % inside that column. Can anyone tell me how can I make it ? Ray - You need to calculate the frequencies in your data. Let's assume your data is in A1:A12. In B1:B3 enter these numbers, the upper limits on the groupings: 3 6 9 You can enter ">9" into B4 witho...

Run-time error 438?
Hello, I am trying to create an edit control for my form. I lock my textboxes in properties and then I created a command button with an event on onclick. My codes are working for most of them expect a few. When I click the button it gives me Run-time error 438. My code is based liked this. Me![Control].Locked=False Private Sub Edit_Record_Click() Me![Drago ID].Locked = False Me![Drago Claim Number].Locked = False Me![Dealer Claim Number].Locked = False Me![Dealer].Locked = False Me![Store].Locked = False Me![Machine Acres].Locked = False Me![Part Fail Date].Locked = False - NOT WORKING ...

Email address not created when a new user is created
All, This issue recently happened in my company. Upon creating a new user, the policy was set to create the smtp and X400 address automaticaly. Now when we create a user the smtp and x400 addresses are not created, and when attempting to setup the new user in outlook, the address cant be found. We are using exchange 2003 SP1 on Win2k3 servers. On Wed, 13 Jul 2005 06:49:07 -0700, "Bryan" <Bryan@discussions.microsoft.com> wrote: >All, >This issue recently happened in my company. Upon creating a new user, the >policy was set to create the smtp and X400 addres...

Exchange 2010 MRM, no log files being created
I'm hoping someone can help me with this issue....it has been driving me crazy for days. I have enabled MRM logging on our exchange server, and I can see that some of the policies are working when I run start-managedfolderassistant. We have a retention policy tag on the deleteditems folder, and this does work. The problem is I am not getting any files in the MRM log directory. C:\Program Files\Microsoft\Exchange Server\V14\Logging\Managed Folder Assistant Events 9021 and 9022 are logged in the Application log, but where are the files? Below is the output of my mai...

when form created
I have a form which was created by someone else (not a form template) which is like a questionnaire with empty boxes to be completed. When the boxes are typed in all the margins move to accommodate the words being typed. Is there a way to fix/lock the original form and then just fill in the blank boxes? I suspect this is set up as a table with auto resizing enabled. Displaying table gridlines (Table | Show Gridlines) will help you see what you're dealing with. Then select the table, go to the Table tab of Table Properties, click Options, and clear the check box for "A...

Creating a Brochure
How do you create a 3-column brochure from scratch for Publisher 2002? I can only find the directions for the 2003 version. Quick help would be appreciated, project is due Monday. Create a three-panel or four-panel folded publication http://office.microsoft.com/en-us/assistance/HP011646681033.aspx Scroll down to the section that says "Build a three-panel or four-panel publications from scratch." -- Mary Sauer MSFT MVP http://office.microsoft.com/ http://msauer.mvps.org/ news://msnews.microsoft.com "Derek" <Derek@discussions.microsoft.com> wrote in message news...

How to create Access macro shortcut
I'm still using Access 97 and saw something the other day that I would like to use that was in Access 2000. In an Access 2000 database, there was a .mam file in a directory that launched the Access 2000 program and ran a macro. How do you set this up? Can it be done in Access 97? If so, how? Hi. > How do you set this up? Select the macro in the Database Window and right click with your mouse, then select "Create Shortcut..." in the pop-up menu. Follow the prompts for where to place the shortcut and what to name it. The default is: <PathToDeskTopDir>\Shortcut ...

Users mailboxes not created when user created
I have a problem that recently just started happening on my exchange 2003 server. When i create a new user account and create the mailbox for exchange, once im done, the mailbox isnt created, adn if you go into the properties of the user account adn go to the exchange email address tab, there isnt an smtp or an x.400 address listed. I am having to manually create and add these, adn then go delete the exchange mailbox and recreate it. This is really annoying and would love to know if anyone has any ideas of how to fix it. Thanks Jason In news:9F836A43-98BF-435A-AA43-AFF10124BE3F@micro...

CRM should let me create custom fields in batch
Hi, With MS CRM v3.0, when we have a group of fields to create, it would be faster to be able to enter the list and then submit the list for processing. Thank you. Felix. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Microsoft Web-based Newsreader and then click "I Agree" in the message pane. http://www.microsoft.com/Businesssolutions/C...

Creating an ad book
How do I divide a page into equal sections (halves, qarters, eights)? I need to scan and type ads and coupons into this booklet. New at this. After managing to set up OE-QuoteFix on his new PC, Ed reads a message from FRSH <anonymous@discussions.microsoft.com>... > How do I divide a page into equal sections (halves, qarters, eights)? Arrange > Layout Guides > Grid Guides -- Ed Bennett - MVP Microsoft Publisher http://www.mvps.org/the_nerd/ Before reading this message, view the disclaimer: http://mvps.org/the_nerd/disclaim.htm ...

Counting entries in column C, based on entries in column A
I would like to count the # of entries of a value in column C, grouped by values in column A. Binder Note Category AA01 abc 2 AA01 ccc 2 AA01 abc 2 AA01 ddd 3 AA22 aaa 1 AA22 ccc 2 Need to find the # of Category 2's , for every Binder # Do not have the nested IF's I have tried available at the moment, but I am getting close... Try this: E1 = some binder code like AA01 E2 = some category number like 2 =SUMPRODUCT(--(A2:A7=E1),--(C2:C7=E2)) Biff <xj6rob@hotmail....