Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / June 2007

Tip: Looking for answers? Try searching our database.

Built-Ins For Date Arithmetic Intervals?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
(PeteCresswell) - 27 Jun 2007 00:26 GMT
Right now, I'm doing this:

' ---------------------------------------------------------------
 Global Const gDateInterval_Day      As String = "d"
 Global Const gDateInterval_Week     As String = "ww"
 Global Const gDateInterval_Month    As String = "m"
 Global Const gDateInterval_Quarter  As String = "q"
 Global Const gDateInterval_Year     As String = "yyyy"
' ---------------------------------------------------------------

But it looks kind of lame in light of my suspicion that
VBA must have built-in constants for those values.

If it does, does anybody know the naming convention?
Signature

PeteCresswell

Jeff Boyce - 27 Jun 2007 00:36 GMT
How are you intending to use these?

Regards

Jeff Boyce
Microsoft Office/Access MVP

> Right now, I'm doing this:
>
[quoted text clipped - 10 lines]
>
> If it does, does anybody know the naming convention?
Tom Wannabe - 27 Jun 2007 15:00 GMT
if you were using SQL Server and ADP then you could do this:

DateDiff(Day, Date1, Date2)

I mean come on guys-- talk about re-inventing the wheel

> How are you intending to use these?
>
[quoted text clipped - 17 lines]
>>
>> If it does, does anybody know the naming convention?
(PeteCresswell) - 28 Jun 2007 13:50 GMT
Per Jeff Boyce:
>How are you intending to use these?

In a routine that spawns records by incrementing dates.

One of the passed arguments is the interval to increment by.
Signature

PeteCresswell

Dirk Goldgar - 28 Jun 2007 15:09 GMT
> Per Jeff Boyce:
>> How are you intending to use these?
>
> In a routine that spawns records by incrementing dates.
>
> One of the passed arguments is the interval to increment by.

Pete -

If you're spawning records (great term!), are you familiar with the
query-cross-product method of generating records?  You start with a
table containing, say, 10 (or 100) records, with a single number field,
numbered from 1 to 10 (or 100).  There are no other fields in the table.
Following the lead of the person who showed my this trick, I usually
call this table "Iotas", and name the field "Iota".  How many records
you seed the table with depends on how many records you are likely to
need to generate.

Now, with this table containing 10 records, if I want to generate 100
records, I use a query that includes the table twice, with no joins
between the two tables, like this:

   qryMake100Records:
       SELECT [A].[Iota]+(10*[B].[Iota]) AS Iota
       FROM Iotas AS A, Iotas AS B;

If I need 1000 records, I include the table three times:

   qryMake1000Records:
       SELECT [A].[Iota]+(10*[B].[Iota])]+(100*[C].[Iota]) AS Iota
       FROM Iotas AS A, Iotas AS B, Iotas AS C;

By including the appropriate "Iotas" query in other queries, I can
generate as many records as I want.  The final query may or may not use
the actual Iota field for anything.  I don't remember who showed me
this, but I've found it quite handy.

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Dirk Goldgar - 27 Jun 2007 08:21 GMT
> Right now, I'm doing this:
>
[quoted text clipped - 10 lines]
>
> If it does, does anybody know the naming convention?

Looking at the VBA object library in the Object Browser, I don't see any
defined constants for those values.

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.