PC Review


Reply
Thread Tools Rate Thread

Calendar Date

 
 
Joe
Guest
Posts: n/a
 
      20th Aug 2010
I need to put criteria in a query for Hire Date. I need it to be
between the first of the year and the current date. I know i can use
the current date as Date(), however I want the first of the year to
NOT be >12/31/2009 and instead be dynamic enough to know when a new
year starts. Ideas?
 
Reply With Quote
 
 
 
 
John W. Vinson
Guest
Posts: n/a
 
      20th Aug 2010
On Fri, 20 Aug 2010 13:02:16 -0700 (PDT), Joe <(E-Mail Removed)> wrote:

>I need to put criteria in a query for Hire Date. I need it to be
>between the first of the year and the current date. I know i can use
>the current date as Date(), however I want the first of the year to
>NOT be >12/31/2009 and instead be dynamic enough to know when a new
>year starts. Ideas?


Try

>= DateSerial(Year(Date()), 1, 1) AND <= Date()


The DateSerial function takes three number arguments, year, month, and day, so
this expression will search from the start of this year (whenever it's run)
and today.
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/For...-US/accessdev/
http://social.answers.microsoft.com/.../en-US/addbuz/
and see also http://www.utteraccess.com
 
Reply With Quote
 
David W. Fenton
Guest
Posts: n/a
 
      21st Aug 2010
John W. Vinson <jvinson@STOP_SPAM.WysardOfInfo.com> wrote in
news:(E-Mail Removed):

> On Fri, 20 Aug 2010 13:02:16 -0700 (PDT), Joe <(E-Mail Removed)>
> wrote:
>
>>I need to put criteria in a query for Hire Date. I need it to be
>>between the first of the year and the current date. I know i can
>>use the current date as Date(), however I want the first of the
>>year to NOT be >12/31/2009 and instead be dynamic enough to know
>>when a new year starts. Ideas?

>
> Try
>
>>= DateSerial(Year(Date()), 1, 1) AND <= Date()

>
> The DateSerial function takes three number arguments, year, month,
> and day, so this expression will search from the start of this
> year (whenever it's run) and today.


You're assuming the field being searched has no time component (a
reasonable assumption), but many people erroneously populate date
fields (like Hire Date) with Now() instead of Date(), so to account
for that, the <= Date() might be replaced with <= Now().

--
David W. Fenton http://www.dfenton.com/
contact via website only http://www.dfenton.com/DFA/
 
Reply With Quote
 
John W. Vinson
Guest
Posts: n/a
 
      22nd Aug 2010
On 21 Aug 2010 19:59:27 GMT, "David W. Fenton" <(E-Mail Removed)>
wrote:

>John W. Vinson <jvinson@STOP_SPAM.WysardOfInfo.com> wrote in
>news:(E-Mail Removed):
>
>> On Fri, 20 Aug 2010 13:02:16 -0700 (PDT), Joe <(E-Mail Removed)>
>> wrote:
>>
>>>I need to put criteria in a query for Hire Date. I need it to be
>>>between the first of the year and the current date. I know i can
>>>use the current date as Date(), however I want the first of the
>>>year to NOT be >12/31/2009 and instead be dynamic enough to know
>>>when a new year starts. Ideas?

>>
>> Try
>>
>>>= DateSerial(Year(Date()), 1, 1) AND <= Date()

>>
>> The DateSerial function takes three number arguments, year, month,
>> and day, so this expression will search from the start of this
>> year (whenever it's run) and today.

>
>You're assuming the field being searched has no time component (a
>reasonable assumption), but many people erroneously populate date
>fields (like Hire Date) with Now() instead of Date(), so to account
>for that, the <= Date() might be replaced with <= Now().


Or even

< DateAdd("d", 1, Date())
--

John W. Vinson [MVP]
Microsoft's replacements for these newsgroups:
http://social.msdn.microsoft.com/For...-US/accessdev/
http://social.answers.microsoft.com/.../en-US/addbuz/
and see also http://www.utteraccess.com
 
Reply With Quote
 
David W. Fenton
Guest
Posts: n/a
 
      22nd Aug 2010
John W. Vinson <jvinson@STOP_SPAM.WysardOfInfo.com> wrote in
news:(E-Mail Removed):

> On 21 Aug 2010 19:59:27 GMT, "David W. Fenton"
> <(E-Mail Removed)> wrote:
>
>>John W. Vinson <jvinson@STOP_SPAM.WysardOfInfo.com> wrote in
>>news:(E-Mail Removed):
>>
>>> On Fri, 20 Aug 2010 13:02:16 -0700 (PDT), Joe
>>> <(E-Mail Removed)> wrote:
>>>
>>>>I need to put criteria in a query for Hire Date. I need it to
>>>>be between the first of the year and the current date. I know i
>>>>can use the current date as Date(), however I want the first of
>>>>the year to NOT be >12/31/2009 and instead be dynamic enough to
>>>>know when a new year starts. Ideas?
>>>
>>> Try
>>>
>>>>= DateSerial(Year(Date()), 1, 1) AND <= Date()
>>>
>>> The DateSerial function takes three number arguments, year,
>>> month, and day, so this expression will search from the start of
>>> this year (whenever it's run) and today.

>>
>>You're assuming the field being searched has no time component (a
>>reasonable assumption), but many people erroneously populate date
>>fields (like Hire Date) with Now() instead of Date(), so to
>>account for that, the <= Date() might be replaced with <= Now().

>
> Or even
>
>< DateAdd("d", 1, Date())


Or, much more simply:

<= Date() + 1

--
David W. Fenton http://www.dfenton.com/
contact via website only http://www.dfenton.com/DFA/
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
click date/time field display calendar and validation of date /tim Smithskenpo Microsoft Outlook Form Programming 0 4th Mar 2010 08:20 PM
2003 Outlook Calendar - End date before start date error dpn941 Microsoft Outlook Calendar 0 13th Sep 2009 09:19 PM
Convert date from Gregorian Calendar to Hijri Calendar H.Alkhodary Microsoft Excel Misc 1 21st Feb 2009 10:11 AM
Problem - Calendar to Inbox to Calendar moves date to current date =?Utf-8?B?amVzc2ljYQ==?= Microsoft Outlook Calendar 1 6th Jun 2005 03:05 PM
Calendar Control - Programatically set the calendar to a date range Shevek Microsoft ASP .NET 3 23rd Jun 2004 02:41 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:01 PM.