Smart questions
Smart answers
Smart people
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

LINK TO THIS FORUM!

Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Partner With Us!

"Best Of Breed" Forums Add Stickiness To Your Site
Partner Button
(Download This Button Today!)

Feedback

"...Your site is one of the cleanest and BEST forums that I have seen. I have sent quite a few people your way. Keep up the good work!!!"

Geography

Where in the world do Tek-Tips members come from?
supportservice (TechnicalUser)
22 May 12 12:25
What is the best way to replace the 366 days ago, as some months it might be 367, etc ... (31 days vs 30 Days, and Feb. with 28 or 29 days) to return a year ago from the date selected on the FromDate?

CODE

(IIf([PostingDate] Between Forms!DateSelector!FromDate-366 And Forms!DateSelector!ToDate-366,([CreditAmount])-[DebitAmount],0))
SkipVought (Programmer)
22 May 12 12:43


A year ago...

CODE

DateSerial(Year([Your Date])-1, Month([Your Date]), Day([Your Date]))

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

supportservice (TechnicalUser)
22 May 12 12:55
Thank you but ...
That returns all of last year?

CODE

Between #4/1/2012#-DateSerial(Year([PostingDate])-1,Month([PostingDate]),Day([PostingDate]))

I am would like this to return, from 4/1/2012, last year up to 3/31/2011.
Not sure how to do that?
SkipVought (Programmer)
22 May 12 12:58
what is the value of [PostingDate]?

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

supportservice (TechnicalUser)
22 May 12 13:01

CODE

LMTD: (IIf([PostingDate] Between [Forms]![DateSelector]![FromDate]-DateSerial(Year([PostingDate])-1,Month([PostingDate]),Day([PostingDate])) And [Forms]![DateSelector]![ToDate]-DateSerial(Year([PostingDate])-1,Month([PostingDate]),Day([PostingDate])),[Amount],0))

Noting that FromDate=4/1/2012 and ToDate=4/30/2012
Need to return data from 1/1/2011 through 4/1/2011 and 1/1/2011 through 4/30/2011
SkipVought (Programmer)
22 May 12 13:04


Well THAT is NOT what you asked for! Please ask what you mean and draw inference.

The first of the year is

CODE

DateSerial(Year([Your Date]), 1, 1)

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

supportservice (TechnicalUser)
22 May 12 13:14
Hi Skip,
Yes, I apologize. Trying to write it out to make sense and convey what I am looking for help in.
Forget the above.

Here is what I have:
[PostingDate] Between [Forms]![DateSelector]![FromDate]-366 And [Forms]![DateSelector]![ToDate]-366

Say the parameters are set to: FromDate = 4/1/2012 and ToDate = 4/30/2012

I need to return data from 1/1/2011 through 4/1/2011 and 1/1/2011 through 4/30/2011

Hope that makes more sense?
SkipVought (Programmer)
22 May 12 13:54


Well then you have the information that you need.

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

supportservice (TechnicalUser)
22 May 12 15:16
Using
Between DateSerial(Year([Forms]![DateSelector]![FromDate])-1,1,1) And DateSerial(Year([Forms]![DateSelector]![ToDate])-1,1,1)

Where FromDate = 4/1/2012 and ToDate = 4/30/12

It's only returning 1/1/2011, which guess makes sense since the DateSerial is to return beginning of the year.

I am expecting it to return 4/1/2011-4/30/2011

So am not sure how to have it return 4/1/2011 - 4/30/2011 and 4/1/2012 - 4/30/2012 are selected?
SkipVought (Programmer)
22 May 12 15:26

You seem very confused, disoriented, befuddled and bewildered.

Your queries and responses seem unrelated.

Frankly, you have perplexed me.

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

supportservice (TechnicalUser)
22 May 12 15:35
I am.

Try from the top.

I currently have:

FromDate = 4/1/2012
ToDate = 4/30/2012

I have: Between Forms!DateSelector!FromDate-366 And Forms!DateSelector!ToDate-366

This gives me data for 4/1/2011 through 4/30/2011, exactly what I need.

----
HOWEVER, in May there are 31 days so the -366 days from the date selection won't be accurate.

I am trying to replace the 366 days so it'll always return the selected month range from the DateSelector for the prior year.

Hope that made better sense. I thought that is what I was asking.

Anyway, to be clear I do not need to know the beginning of the year but rather the prior year based on the date selected, which will always be the current year's month range that are entered.
supportservice (TechnicalUser)
22 May 12 15:35
How many different ways of asking that until it's understood is unsure. I don't know how else to ask the question.
supportservice (TechnicalUser)
22 May 12 15:38
Simplifying it to

How to get 4/1/2011 through 4/30/2011 data returned when the user enters 4/1/2012 through 4/30/2012?

Basically need to know the prior year's data for the date selected, which will always be the current year.
SkipVought (Programmer)
22 May 12 15:46


I just reread your last post. You have been all over the place!

It is the first time that you stated that you wanted a critera from Year To Date CURRENT year and Year To Date of the PREVIOUS year. I summarily dismissed you because you previously specified nonsense.

So here is what it seems you have stated for the first time...

CODE

where [SomeDate] Between DateSerial(Year([Forms]![DateSelector]![FromDate])-1,1,1) And DateSerial(Year([Forms]![DateSelector]![ToDate])-1, Month([Forms]![DateSelector]![ToDate]), Day([Forms]![DateSelector]![ToDate])) OR [SomeDate] Between DateSerial(Year([Forms]![DateSelector]![FromDate]),1,1) And [Forms]![DateSelector]![ToDate]

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

supportservice (TechnicalUser)
22 May 12 16:00
Ok thank you.

The first line returns 1/1/2011 - 4/30/2011

So much closer now.

How do I limit it to be from 4/1/2011 to 4/30/2011?

As noted, need it to be the prior year's month range from the selected month range.

Selected 4/1/2012 - 4/30/2012
Return 4/1/2011 - 4/30/2011
SkipVought (Programmer)
22 May 12 16:08


I have given you numerous examples of using the DateSerial(), Year(), Month() & Day() functions, and two where clause criteria.

If you cannot subsequently craft a solution and TEST and modify as required, you probably need to hire professional help.

Skip,

glassesJust traded in my old subtlety...
for a NUANCE!tongue

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close