INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

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.

Jobs

A string is required here

A string is required here

(OP)
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

RE: A string is required here

Can you please explain what value you want to assign to variable rephead?

RE: A string is required here

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}

RE: A string is required here

(OP)
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

RE: A string is required here


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.

RE: A string is required here

(OP)
I want it to look at yesterdays date everytime the report runs

RE: A string is required here

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.

RE: A string is required here

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

RE: A string is required here

(OP)
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


RE: A string is required here

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

RE: A string is required here

(OP)
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

RE: A string is required here

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)

RE: A string is required here

(OP)
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

RE: A string is required here

You can test it by changing it to go back 2 days on a Wednesday

RE: A string is required here

(OP)
Hi

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

Thanks

RE: A string is required here

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

RE: A string is required here

(OP)
Hi

yes that works perfect and gave Mondays date.

Many thanks

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!

Resources

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