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  

Return a date range based on today's date



 
 
Thread Tools Display Modes
  #11  
Old December 1st, 2009, 05:36 PM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Return a date range based on today's date

On Tue, 1 Dec 2009 08:08:01 -0800, BABs
wrote:

I need to build a query (to be used for eternity) to return records for dates
between 01 July (the year prior) and 30 Jun (the current year) based on the
date when the query is run.
Is this possible?


Not just possible but easy:

= DateSerial(Year(Date()) - 1, 7, 1) AND DateSerial(Year(Date()), 7, 1)


--

John W. Vinson [MVP]
  #12  
Old December 1st, 2009, 05:36 PM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Return a date range based on today's date

On Tue, 1 Dec 2009 08:08:01 -0800, BABs
wrote:

I need to build a query (to be used for eternity) to return records for dates
between 01 July (the year prior) and 30 Jun (the current year) based on the
date when the query is run.
Is this possible?


Not just possible but easy:

= DateSerial(Year(Date()) - 1, 7, 1) AND DateSerial(Year(Date()), 7, 1)


--

John W. Vinson [MVP]
  #13  
Old December 1st, 2009, 05:36 PM posted to microsoft.public.access.queries
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Return a date range based on today's date

On Tue, 1 Dec 2009 08:08:01 -0800, BABs
wrote:

I need to build a query (to be used for eternity) to return records for dates
between 01 July (the year prior) and 30 Jun (the current year) based on the
date when the query is run.
Is this possible?


Not just possible but easy:

= DateSerial(Year(Date()) - 1, 7, 1) AND DateSerial(Year(Date()), 7, 1)


--

John W. Vinson [MVP]
  #14  
Old December 1st, 2009, 06:05 PM posted to microsoft.public.access.queries
vanderghast
external usenet poster
 
Posts: 593
Default Return a date range based on today's date

I assumed you want to GENERATE all the date; if you already have the records
and wish to limit yourself to the interval, use one of the other
propositions.

I missed a Day( ) in my where clause:

WHERE iota= iif(Day(DateSerial( 1+Year( DateAdd("m", -6, now()) ), 2, 29 ))
=29 , 366, 365)



Vanderghast, Access MVP


"vanderghast" vanderghast@com wrote in message
...
If you have a driver table, a table with one field, with values for 0 to
366 (at least). Say that table is called Iotas, and its field, iota, also
its primary key.

--- untested---
SELECT DateSerial( Year( DateAdd("m", -6, now( ) )), 7, 1) + Iotas.Iota
FROM Iotas
WHERE iota= iif(DateSerial( 1+Year( DateAdd("m", -6, now()) ), 2, 29 )
=29 , 366, 365)




The idea is to check if this is a leap year or not (to take 366 or 365
days), and to add all of them to the first of July of the proper year.



Vanderghast, Access MVP



"BABs" wrote in message
...
I need to build a query (to be used for eternity) to return records for
dates
between 01 July (the year prior) and 30 Jun (the current year) based on
the
date when the query is run.
Is this possible?



  #15  
Old December 1st, 2009, 06:05 PM posted to microsoft.public.access.queries
vanderghast
external usenet poster
 
Posts: 593
Default Return a date range based on today's date

I assumed you want to GENERATE all the date; if you already have the records
and wish to limit yourself to the interval, use one of the other
propositions.

I missed a Day( ) in my where clause:

WHERE iota= iif(Day(DateSerial( 1+Year( DateAdd("m", -6, now()) ), 2, 29 ))
=29 , 366, 365)



Vanderghast, Access MVP


"vanderghast" vanderghast@com wrote in message
...
If you have a driver table, a table with one field, with values for 0 to
366 (at least). Say that table is called Iotas, and its field, iota, also
its primary key.

--- untested---
SELECT DateSerial( Year( DateAdd("m", -6, now( ) )), 7, 1) + Iotas.Iota
FROM Iotas
WHERE iota= iif(DateSerial( 1+Year( DateAdd("m", -6, now()) ), 2, 29 )
=29 , 366, 365)




The idea is to check if this is a leap year or not (to take 366 or 365
days), and to add all of them to the first of July of the proper year.



Vanderghast, Access MVP



"BABs" wrote in message
...
I need to build a query (to be used for eternity) to return records for
dates
between 01 July (the year prior) and 30 Jun (the current year) based on
the
date when the query is run.
Is this possible?



  #16  
Old December 1st, 2009, 06:05 PM posted to microsoft.public.access.queries
vanderghast
external usenet poster
 
Posts: 593
Default Return a date range based on today's date

I assumed you want to GENERATE all the date; if you already have the records
and wish to limit yourself to the interval, use one of the other
propositions.

I missed a Day( ) in my where clause:

WHERE iota= iif(Day(DateSerial( 1+Year( DateAdd("m", -6, now()) ), 2, 29 ))
=29 , 366, 365)



Vanderghast, Access MVP


"vanderghast" vanderghast@com wrote in message
...
If you have a driver table, a table with one field, with values for 0 to
366 (at least). Say that table is called Iotas, and its field, iota, also
its primary key.

--- untested---
SELECT DateSerial( Year( DateAdd("m", -6, now( ) )), 7, 1) + Iotas.Iota
FROM Iotas
WHERE iota= iif(DateSerial( 1+Year( DateAdd("m", -6, now()) ), 2, 29 )
=29 , 366, 365)




The idea is to check if this is a leap year or not (to take 366 or 365
days), and to add all of them to the first of July of the proper year.



Vanderghast, Access MVP



"BABs" wrote in message
...
I need to build a query (to be used for eternity) to return records for
dates
between 01 July (the year prior) and 30 Jun (the current year) based on
the
date when the query is run.
Is this possible?



  #17  
Old December 1st, 2009, 09:40 PM posted to microsoft.public.access.queries
babs
external usenet poster
 
Posts: 409
Default Return a date range based on today's date

Awesome....thx

"John W. Vinson" wrote:

On Tue, 1 Dec 2009 08:08:01 -0800, BABs
wrote:

I need to build a query (to be used for eternity) to return records for dates
between 01 July (the year prior) and 30 Jun (the current year) based on the
date when the query is run.
Is this possible?


Not just possible but easy:

= DateSerial(Year(Date()) - 1, 7, 1) AND DateSerial(Year(Date()), 7, 1)


--

John W. Vinson [MVP]
.

  #18  
Old December 1st, 2009, 09:40 PM posted to microsoft.public.access.queries
babs
external usenet poster
 
Posts: 409
Default Return a date range based on today's date

Awesome....thx

"John W. Vinson" wrote:

On Tue, 1 Dec 2009 08:08:01 -0800, BABs
wrote:

I need to build a query (to be used for eternity) to return records for dates
between 01 July (the year prior) and 30 Jun (the current year) based on the
date when the query is run.
Is this possible?


Not just possible but easy:

= DateSerial(Year(Date()) - 1, 7, 1) AND DateSerial(Year(Date()), 7, 1)


--

John W. Vinson [MVP]
.

  #19  
Old December 1st, 2009, 09:40 PM posted to microsoft.public.access.queries
babs
external usenet poster
 
Posts: 409
Default Return a date range based on today's date

Awesome....thx

"John W. Vinson" wrote:

On Tue, 1 Dec 2009 08:08:01 -0800, BABs
wrote:

I need to build a query (to be used for eternity) to return records for dates
between 01 July (the year prior) and 30 Jun (the current year) based on the
date when the query is run.
Is this possible?


Not just possible but easy:

= DateSerial(Year(Date()) - 1, 7, 1) AND DateSerial(Year(Date()), 7, 1)


--

John W. Vinson [MVP]
.

 




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 03:16 AM.


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