×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • 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!

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

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

If AND then else?

If AND then else?

If AND then else?

(OP)
Hello,
I can't seem to get this right.

CODE

If {PR_EmployeeTaxHistory.CalendarMonth} = "01" and ToNumber({PR_EmployeeTaxHistory.CalendarYear}) = Year(CurrentDate()) then ToNumber({PR_EmployeeTaxHistory.CalendarYear}) = Year(CurrentDate())-1 else
ToNumber({PR_EmployeeTaxHistory.CalendarYear}) = Year(CurrentDate()) 

What is the proper syntax?

I'm trying to have it return last year's data IF it's the current month (January) and current year only.

This is to run 4th quarter data after the end of the year.
So today is a new year and needs to be still producing last year's data then in Feb it'll show the current year's data, etc ....

RE: If AND then else?

I think something like this should get you just the year or the year-1 which you could then use in selection criteria.
I would use variables, but depending on your case use they might not be necessary.

{@YearChange}
whileprintingrecords;
numbervar qtrsel;

If {PR_EmployeeTaxHistory.CalendarMonth} = "01" and ToNumber({PR_EmployeeTaxHistory.CalendarYear}) = Year(CurrentDate()) then
qtrsel := Year(CurrentDate())-1
else qtrsel := Year(CurrentDate())

RE: If AND then else?

(OP)
Not sure how to apply your suggestion with the

{@YearChange}
whileprintingrecords;
numbervar qtrsel;

This is currently the entire Report select formulas

CODE

If ({PR_EmployeeTaxHistory.CalendarMonth} = "01" and ToNumber({PR_EmployeeTaxHistory.CalendarYear}) = Year(CurrentDate())) then (ToNumber({PR_EmployeeTaxHistory.CalendarYear}) = Year(CurrentDate())-1) else
ToNumber({PR_EmployeeTaxHistory.CalendarYear}) = Year(CurrentDate()) and
{PR_EmployeeTaxHistory.TaxGroup} = {?Tax Group} 

With this I get last year's data but do not want anyone to have to go in and remove it come February

CODE

ToNumber({PR_EmployeeTaxHistory.CalendarYear}) = Year(CurrentDate())-1 and
{PR_EmployeeTaxHistory.TaxGroup} = {?Tax Group} 

RE: If AND then else?


You should not have to make any changes come February.
The month will not be 01 so the year will be year of the current date.
It looks like the Report select formula you already have should almost work without any need for my previous post.


If
({PR_EmployeeTaxHistory.CalendarMonth} = "01" and ToNumber({PR_EmployeeTaxHistory.CalendarYear}) = Year(CurrentDate()))
then
(ToNumber({PR_EmployeeTaxHistory.CalendarYear}) = Year(CurrentDate())-1
and
{PR_EmployeeTaxHistory.TaxGroup} = {?Tax Group})
else
(ToNumber({PR_EmployeeTaxHistory.CalendarYear}) = Year(CurrentDate())
and
{PR_EmployeeTaxHistory.TaxGroup} = {?Tax Group})

RE: If AND then else?

(OP)
It still comes up blank
only time it produces the data for last year is by this

ToNumber({PR_EmployeeTaxHistory.CalendarYear}) = Year(CurrentDate())-1 and
{PR_EmployeeTaxHistory.TaxGroup} = {?Tax Group}

RE: If AND then else?

(OP)
Tried this as well, doesn't work either :(

CODE

If 
(Month(CurrentDate)= 1 and ToNumber({PR_EmployeeTaxHistory.CalendarYear}) = Year(CurrentDate()))
then 
(ToNumber({PR_EmployeeTaxHistory.CalendarYear}) = Year(CurrentDate())-1
and
{PR_EmployeeTaxHistory.TaxGroup} = {?Tax Group})
else
(ToNumber({PR_EmployeeTaxHistory.CalendarYear}) = Year(CurrentDate()) 
and
{PR_EmployeeTaxHistory.TaxGroup} = {?Tax Group}) 

RE: If AND then else?

(OP)
Got this from DBlank and seems to be working now

CODE

( 
(MONTH(today)=1 and 
ToNumber({PR_EmployeeTaxHistory.CalendarYear}) = Year(today)-1) 
OR 
((MONTH(today)>1 and ToNumber({PR_EmployeeTaxHistory.CalendarYear}) = Year(today)) 
) 
and 
{PR_EmployeeTaxHistory.TaxGroup} = {?Tax Group}) 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

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! Already a Member? Login

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