Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

A string is required here

Status
Not open for further replies.

Cpreston

MIS
Mar 4, 2015
969
0
16
GB
I have the following formula which I am trying to adapt so it looks at yesterdays date but it saying a string is required here

stringvar rephead;

rephead := "For Delivery on: " + {OrderHeader.DeliveryDate}=CurrentDate -1;


rephead

How can I get the formula correct so the string is correct, thanks
 
Can you please explain what value you want to assign to variable rephead?

 
if you change the plus(+) to an "&", it will treat the date {OrderHeader.DeliveryDate} as a string for your string variable 'rephead'

rephead := "For Delivery on: " & {OrderHeader.DeliveryDate}
 
Hi

I am now getting the same message but for the =currentdate-1, any ideas please

stringvar rephead;


rephead := "For Delivery on: " & {OrderHeader.DeliveryDate} = CurrentDate-1;


rephead
 

You have to use totext as follows:
rephead := "For Delivery on: " + totext({OrderHeader.DeliveryDate});

What I am trying to figure out is why you have=currentdate-1 at the end.
 
I want it to look at yesterdays date everytime the report runs

 
note that :

rephead := "For Delivery on: " + totext({OrderHeader.DeliveryDate})
and
rephead := "For Delivery on: " & {OrderHeader.DeliveryDate}

will both work. The & causes the date field to be treated as totext

This doesn't address the '=currentdate-1' at the end part of the issue.
 
It looks like the {OrderHeader.DeliveryDate} = CurrentDate-1 should be in your select formula, not the header.

Then your header would simply be: "For Delivery On: "&CurrentDate-1
 
Hi

In my Select expert I now have

{OrderHeader.DateTimeCreated} = currentdate-1

and this works ok, gives yesterdays date

However, If it is Monday then it will look at Sundays date, where I really want it to look at fridays dates, any ideas how I can set the formula

If DayOfWeek = 1 then {OrderHeader.DateTimeCreated} = CurrentDate-3
else {OrderHeader.DateTimeCreated} = CurrentDate-1

The result of this is an error message there is not enough arguments.

Any ideas how I can get the formula to work please. Thanks as always


 
{OrderHeader.DateTimeCreated} =
(If DayOfWeek = 1 then
CurrentDate-3
else CurrentDate-1)
 
Hi

Thanks for the reply. I tried your code but still says there is not enough arguments

{OrderHeader.DateTimeCreated} =
(If DayOfWeek = 1 then
CurrentDate-3
else CurrentDate-1)

I managed to do this earlier and I got no error messages

If DayOfWeek(currentdate,CRMonday) = 1 then {OrderHeader.DateTimeCreated} = CurrentDate-3
else {OrderHeader.DateTimeCreated} = CurrentDate-1


It runs ok but will not know if it works until Monday when it should give me Fridays date and figures from the previous week.

Thanks
 
Okay, I was thinking thar DayOfWeek was a formula that you had defined elsewhere. Change the formula to:

{OrderHeader.DateTimeCreated} =
(If DayOfWeek(currentdate) = 2 then
CurrentDate-3
else CurrentDate-1)

 
Hi

Thanks will give your code ago, again wont know if it works until next Monday, I will update the post.

Thanks for the help
 
You can test it by changing it to go back 2 days on a Wednesday
 
Hi

Sorry how do I turn it back 2 days, just tried with the coding but it goes to sunday?

Thanks
 
Here's how we can test it on Thursday.

{OrderHeader.DateTimeCreated} =
(If DayOfWeek(currentdate) = 5 then
CurrentDate-3
else CurrentDate-1)

That should give you Monday
 
Hi

yes that works perfect and gave Mondays date.

Many thanks

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top