Convert Date Expression to DateFormula

spiky_goldenspiky_golden Member Posts: 44
I have some difficulty to convert expression like "-CW" into a date formulavariable. We are using both French and English environment so using "-CW" is cause quite a issue.

What I need to do is to calculate the first day of the current week. Then Find the first day and the last day of next week and the same thing for the week after.
1- I'm using "-CW " to get the first day of the current week.
2- I'm using "+1W" to get the first day of the next week from the date find in step 1
3- Then "+1W-1D" from the date find in step 2 and so on...

It is working great as long as the users don’t use the French version... I Read that using DateFormula variable will become language insensitive but I can't figure it out...

Any idea on how i can convert the code?
Patrick Venner
programmeur-analyste
Cabico Custom Cabinetry

Answers

  • krikikriki Member, Moderator Posts: 9,110
    To make the dateformulas international, use < and >. Example : '<1M>' or '<CW>'.
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


  • spiky_goldenspiky_golden Member Posts: 44
    kriki, it works like a charm!

    Thanks
    Patrick Venner
    programmeur-analyste
    Cabico Custom Cabinetry
  • vaprogvaprog Member Posts: 1,139
    I have some difficulty to convert expression like "-CW" into a date formulavariable. We are using both French and English environment so using "-CW" is cause quite a issue.

    ...

    It is working great as long as the users don’t use the French version... I Read that using DateFormula variable will become language insensitive but I can't figure it out...

    To assign to a DateFormula variable you need to use EVALUATE unless you have a value of type DateFormula already that is stored in some variable or field. C/AL does not provide any way to specify a DateFormula constant. So, all you can do is provide the formula as a string, which is language sensitive unless surrounded by < and > as kriki said.

    Btw, CALCDATE takes a text, code or dateformula as its DateExpression parameter.
  • spiky_goldenspiky_golden Member Posts: 44
    In fact with the '<>' trick I don't even need dateformula. Everything works like a charm I just wish I had read the doc carefully as I just read it this morning... But hey, no one is perfect!
    Patrick Venner
    programmeur-analyste
    Cabico Custom Cabinetry
  • krikikriki Member, Moderator Posts: 9,110
    Let's throw in some Chinese ... euh ... informatics saying: When all else fails, try to read the <beeeeep> manual. :lol:
    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.