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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Crystal Syntax V7 Equivalent for datediff,dateadd etc

Status
Not open for further replies.

rscherer

Programmer
Mar 26, 2004
2
CA
I am looking for the Crystal Syntax (V7) for the datediff,Dateadd VB syntax functionality.

Here's the example I am trying to convert.

DateAdd("d', -(Weekday({Date_Time_Field}), crSunday} -1), ({Date_Time_Field})

You can see that I any trying to return a string of the first day of the week.
 
Not sure what functions are available in 7.0, but you could try:

{table.date}-dayofweek({table.date})+1

To get the weekday, use:

weekdayname(dayofweek({table.date}-dayofweek({table.date})+1))

-LB
 
V7 does not have a function called dayofweek where you can actually find the first day in the week. It does have a function called weekday which only returns the day number. The date functions are very limited compared to 8+.
 
Your database probably supports this, so you could use a SQL Expression.

Had you shared the database being used, one might be able to help you.

From what I see of your formula, you're trying to return a date, not a string of the date.

Rather than a brief post using text to describe the intent, try posting:

Crystal version
Database used
Example data
Expected output

Even in CR 7 I think that in the SQL Expressions you'll find the dayofweek function available on the database side.

You might also try maximum(lastfullweek)+2

To convert it to a string use:

totext(maximum(lastfullweek)+2)

-k
 
Weekday is the same as dayofweek, so try:

{table.date}-weekday({table.date})+1

This will give you the first day of the week, assuming a Sunday start.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top