A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Between dates



 
 
Thread Tools Display Modes
  #1  
Old December 18th, 2009, 08:33 PM posted to microsoft.public.access.queries
Chi
external usenet poster
 
Posts: 299
Default Between dates

Hi

Would you please show me how to make a query that would list all the dates
occurring between two days, including Beginning Date and Eding Date?

Ex: 12/01/2009 to 12/04/2009
It will give me the list like this: 12/01/2009,12/02/2009, 12/03/2009,
12/04/2009

Thanks,

Chi

  #2  
Old December 18th, 2009, 09:14 PM posted to microsoft.public.access.queries
KARL DEWEY
external usenet poster
 
Posts: 10,767
Default Between dates

Create a table named CountNumber with field CountNUM containg numbers from 0
(zero) through your maximum spread.

SELECT DateAdd("d", [CountNUM], [Enter start date]) AS Date_List
FROM CountNumber
WHERE CountNUM Between [Enter start date] AND [Enter end date];

--
Build a little, test a little.


"Chi" wrote:

Hi

Would you please show me how to make a query that would list all the dates
occurring between two days, including Beginning Date and Eding Date?

Ex: 12/01/2009 to 12/04/2009
It will give me the list like this: 12/01/2009,12/02/2009, 12/03/2009,
12/04/2009

Thanks,

Chi

  #3  
Old December 18th, 2009, 10:04 PM posted to microsoft.public.access.queries
Chi
external usenet poster
 
Posts: 299
Default Between dates

Hi Dewey,

Thank you very much! I will try it and let you know!!
Chi

"KARL DEWEY" wrote:

Create a table named CountNumber with field CountNUM containg numbers from 0
(zero) through your maximum spread.

SELECT DateAdd("d", [CountNUM], [Enter start date]) AS Date_List
FROM CountNumber
WHERE CountNUM Between [Enter start date] AND [Enter end date];

--
Build a little, test a little.


"Chi" wrote:

Hi

Would you please show me how to make a query that would list all the dates
occurring between two days, including Beginning Date and Eding Date?

Ex: 12/01/2009 to 12/04/2009
It will give me the list like this: 12/01/2009,12/02/2009, 12/03/2009,
12/04/2009

Thanks,

Chi

  #4  
Old December 18th, 2009, 10:21 PM posted to microsoft.public.access.queries
fredg
external usenet poster
 
Posts: 4,386
Default Between dates

On Fri, 18 Dec 2009 12:33:01 -0800, Chi wrote:

Hi

Would you please show me how to make a query that would list all the dates
occurring between two days, including Beginning Date and Eding Date?

Ex: 12/01/2009 to 12/04/2009
It will give me the list like this: 12/01/2009,12/02/2009, 12/03/2009,
12/04/2009

Thanks,

Chi


For what purpose?
Creating a table of dates, using VBA, is quite simple.
Create a new table. Name it "tblDates"
Add one field, [TheDate], DateTime datatype.
Then copy and paste the following code into a module:

Public Sub FillDates()
' Will fill a Date Field with consecutive date values.
Dim dteDateFrom As Date
Dim dteDateTo As Date
Dim db As DAO.Database
Dim rs As Recordset
Dim intX As Integer
Set db = CurrentDb
Set rs = db.OpenRecordset("tblDates")

dteDateFrom = InputBox("Enter Starting date")
dteDateTo = InputBox("Enter Ending date")
With rs
Do While intX = (dteDateTo - dteDateFrom)
.AddNew
!TheDate = DateAdd("d", intX, dteDateFrom)
.Update
intX = intX + 1
Loop
End With
Set db = Nothing
Set rs = Nothing
End Sub

You can then run this module, entering the 2 dates when prompted, and
it will fill the table with consecutive dates.
Add error handling as needed.
Now what?

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
  #5  
Old December 21st, 2009, 04:21 PM posted to microsoft.public.access.queries
Chi
external usenet poster
 
Posts: 299
Default Between dates

Good Morning Fredg,

Thank you for the response!
I created the "tblDates" that has one field, [TheDate], DateTime datatype.

would you show me more detail on how creating a module and how to run it?
Sorry I don't know VBA.

Thanks
Chi



"fredg" wrote:

On Fri, 18 Dec 2009 12:33:01 -0800, Chi wrote:

Hi

Would you please show me how to make a query that would list all the dates
occurring between two days, including Beginning Date and Eding Date?

Ex: 12/01/2009 to 12/04/2009
It will give me the list like this: 12/01/2009,12/02/2009, 12/03/2009,
12/04/2009

Thanks,

Chi


For what purpose?
Creating a table of dates, using VBA, is quite simple.
Create a new table. Name it "tblDates"
Add one field, [TheDate], DateTime datatype.
Then copy and paste the following code into a module:

Public Sub FillDates()
' Will fill a Date Field with consecutive date values.
Dim dteDateFrom As Date
Dim dteDateTo As Date
Dim db As DAO.Database
Dim rs As Recordset
Dim intX As Integer
Set db = CurrentDb
Set rs = db.OpenRecordset("tblDates")

dteDateFrom = InputBox("Enter Starting date")
dteDateTo = InputBox("Enter Ending date")
With rs
Do While intX = (dteDateTo - dteDateFrom)
.AddNew
!TheDate = DateAdd("d", intX, dteDateFrom)
.Update
intX = intX + 1
Loop
End With
Set db = Nothing
Set rs = Nothing
End Sub

You can then run this module, entering the 2 dates when prompted, and
it will fill the table with consecutive dates.
Add error handling as needed.
Now what?

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
.

  #6  
Old December 21st, 2009, 05:36 PM posted to microsoft.public.access.queries
fredg
external usenet poster
 
Posts: 4,386
Default Between dates

On Mon, 21 Dec 2009 08:21:01 -0800, Chi wrote:

Good Morning Fredg,

Thank you for the response!
I created the "tblDates" that has one field, [TheDate], DateTime datatype.

would you show me more detail on how creating a module and how to run it?
Sorry I don't know VBA.

Thanks
Chi

"fredg" wrote:

On Fri, 18 Dec 2009 12:33:01 -0800, Chi wrote:

Hi

Would you please show me how to make a query that would list all the dates
occurring between two days, including Beginning Date and Eding Date?

Ex: 12/01/2009 to 12/04/2009
It will give me the list like this: 12/01/2009,12/02/2009, 12/03/2009,
12/04/2009

Thanks,

Chi


For what purpose?
Creating a table of dates, using VBA, is quite simple.
Create a new table. Name it "tblDates"
Add one field, [TheDate], DateTime datatype.
Then copy and paste the following code into a module:

Public Sub FillDates()
' Will fill a Date Field with consecutive date values.
Dim dteDateFrom As Date
Dim dteDateTo As Date
Dim db As DAO.Database
Dim rs As Recordset
Dim intX As Integer
Set db = CurrentDb
Set rs = db.OpenRecordset("tblDates")

dteDateFrom = InputBox("Enter Starting date")
dteDateTo = InputBox("Enter Ending date")
With rs
Do While intX = (dteDateTo - dteDateFrom)
.AddNew
!TheDate = DateAdd("d", intX, dteDateFrom)
.Update
intX = intX + 1
Loop
End With
Set db = Nothing
Set rs = Nothing
End Sub

You can then run this module, entering the 2 dates when prompted, and
it will fill the table with consecutive dates.
Add error handling as needed.
Now what?

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
.


Highlight the sub procedure in my first reply (everything from Public
Sub FillDates() through End Sub). Copy the highlighted code by
pressing Ctrl + C or Edit + Copy.

Then, in your database, click on Modules + New.

When the code window opens the first two lines of the code window
should read

Option Explicit
Option Compare Database

If those 2 lines are not there, write them at the top of the code
window.

Then, place your cursor within the code window (under those top 2
lines) and Paste the code, using Ctrl+V or Edit + Paste, etc.
Exit the code window. When prompted, name the module "mdlFillDates".

When ready to run this code, place the cursor anywhere within the
procedure between Public SubFillDates and End Sub.
Press F5.
When prompted, enter the Start and End dates.
The table will fill with dates.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
  #7  
Old December 21st, 2009, 07:44 PM posted to microsoft.public.access.queries
Chi
external usenet poster
 
Posts: 299
Default Between dates

Hi Fredg,

Thank you very much! I works very well.

"fredg" wrote:

On Mon, 21 Dec 2009 08:21:01 -0800, Chi wrote:

Good Morning Fredg,

Thank you for the response!
I created the "tblDates" that has one field, [TheDate], DateTime datatype.

would you show me more detail on how creating a module and how to run it?
Sorry I don't know VBA.

Thanks
Chi

"fredg" wrote:

On Fri, 18 Dec 2009 12:33:01 -0800, Chi wrote:

Hi

Would you please show me how to make a query that would list all the dates
occurring between two days, including Beginning Date and Eding Date?

Ex: 12/01/2009 to 12/04/2009
It will give me the list like this: 12/01/2009,12/02/2009, 12/03/2009,
12/04/2009

Thanks,

Chi

For what purpose?
Creating a table of dates, using VBA, is quite simple.
Create a new table. Name it "tblDates"
Add one field, [TheDate], DateTime datatype.
Then copy and paste the following code into a module:

Public Sub FillDates()
' Will fill a Date Field with consecutive date values.
Dim dteDateFrom As Date
Dim dteDateTo As Date
Dim db As DAO.Database
Dim rs As Recordset
Dim intX As Integer
Set db = CurrentDb
Set rs = db.OpenRecordset("tblDates")

dteDateFrom = InputBox("Enter Starting date")
dteDateTo = InputBox("Enter Ending date")
With rs
Do While intX = (dteDateTo - dteDateFrom)
.AddNew
!TheDate = DateAdd("d", intX, dteDateFrom)
.Update
intX = intX + 1
Loop
End With
Set db = Nothing
Set rs = Nothing
End Sub

You can then run this module, entering the 2 dates when prompted, and
it will fill the table with consecutive dates.
Add error handling as needed.
Now what?

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
.


Highlight the sub procedure in my first reply (everything from Public
Sub FillDates() through End Sub). Copy the highlighted code by
pressing Ctrl + C or Edit + Copy.

Then, in your database, click on Modules + New.

When the code window opens the first two lines of the code window
should read

Option Explicit
Option Compare Database

If those 2 lines are not there, write them at the top of the code
window.

Then, place your cursor within the code window (under those top 2
lines) and Paste the code, using Ctrl+V or Edit + Paste, etc.
Exit the code window. When prompted, name the module "mdlFillDates".

When ready to run this code, place the cursor anywhere within the
procedure between Public SubFillDates and End Sub.
Press F5.
When prompted, enter the Start and End dates.
The table will fill with dates.
--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
.

  #8  
Old December 21st, 2009, 07:46 PM posted to microsoft.public.access.queries
Chi
external usenet poster
 
Posts: 299
Default Between dates

Hi Karl,
Thank you very much for your help!
Chi

"KARL DEWEY" wrote:

Create a table named CountNumber with field CountNUM containg numbers from 0
(zero) through your maximum spread.

SELECT DateAdd("d", [CountNUM], [Enter start date]) AS Date_List
FROM CountNumber
WHERE CountNUM Between [Enter start date] AND [Enter end date];

--
Build a little, test a little.


"Chi" wrote:

Hi

Would you please show me how to make a query that would list all the dates
occurring between two days, including Beginning Date and Eding Date?

Ex: 12/01/2009 to 12/04/2009
It will give me the list like this: 12/01/2009,12/02/2009, 12/03/2009,
12/04/2009

Thanks,

Chi

 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:43 PM.


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