Advanced Date Calculations is it possible

User-to-User discussion about the PhraseExpress macro programming.
Peter Stotz
PhraseExpress Expert
Posts: 850
Joined: 27 Feb 08, 15:07

Re: Advanced Date Calculations is it possible

Post by Peter Stotz » 14 Nov 19, 20:39

@Thorr
Technical Support wrote:
„Replacing dd.mm.yyyy with ddddd should fix the problem.“

Ok - so please test with date format "ddddd" instead of "dd.mm.yyyy"

Peter Stotz
Windows 10 - PhraseExpress v14.0.168

Praia
Posts: 79
Joined: 01 Apr 14, 01:06

Post by Praia » 16 Nov 19, 20:22

One thing I do not understand is...

Technical Support wrote:
„Replacing dd.mm.yyyy with ddddd should fix the problem.“

I am not in the UK and the phrase works just fine for me, with "-locale en-GB" or without.

Just for fun I changed the setting in the Phrase as follows (mix of . and - as well as change the locale for one)

Code: Select all

(* 20191009 • Order tracking Version 1 with #calendar/#input - without forms
*){#settemp -name ##ordered_on -content {#calendar -f dd.mm.yyyy -head Order placed on… -manual -locale en-GB}}(* 
*){#settemp -name ##day_offset -content {#input -head Ordered on {#gettemp ##ordered_on} • How many delivery time in days? -def +5 -single -required}}(* 
  delivery deadline ##du_day
*){#settemp -name ##du_day -content {#datetime -f dd.mm.yyyy -value {#gettemp ##ordered_on} -s {#gettemp ##day_offset}w -locale en-GB}}(* 
  Delivery time expired?
*){#check -text {#datetime -a -value {#gettemp ##du_day} -locale en-GB} -case < {#datetime -a -locale en-GB} -output Hello Guys
Please, could you get one of your Logistics Team members to chase up the shipping status for this order?
The order was placed on {#datetime -f  dddd, dd-mm-yyyy -value {#gettemp ##ordered_on} -locale is-IS}.

The Costco website shows the shipping for this item is {#gettemp ##day_offset} business days.

This should have been delivered on {#datetime -f  dddd, dd-mm-yyyy -value {#gettemp ##du_day} -locale en-GB}

The item is now {#datecalc -date2 {#gettemp ##du_day} -mode 3} business days late!
The item is now {#calc {#datetime -a -value {#gettemp ##du_day} -locale en-GB}-{#datetime -a -locale en-GB} -round 0} calendar days late!

I need this to update my customer and avoid cancellation of the order.(* 
  Delivery time not yet expired → Windows Notification
*) -else {#balloon -title Delivery time not yet expired: -text ##du_day: {#gettemp ##du_day} -onclick {#datetime -f ddd, dd.mm.yyyy -value {#gettemp ##du_day} -locale en-GB}}}
and it still works just fine. What am I missing here?

rgds

Technical Support
Posts: 2489
Joined: 10 Feb 06, 22:23

Post by Technical Support » 18 Nov 19, 10:03

Well, it works because you use dd.mm.yyyy format everywhere, which is the one used in continental European countries and is not language specific, so -locale en-GB does in fact nothing.

Praia
Posts: 79
Joined: 01 Apr 14, 01:06

Post by Praia » 18 Nov 19, 18:49

I should not work so late.
Found the error of my ways.

Praia
Posts: 79
Joined: 01 Apr 14, 01:06

Post by Praia » 18 Nov 19, 21:30

@Thorrrr

There is a new version of PhraseExpress (14.0.167) out that will allow negative date calculations.
Now I have re done it, have a look, maybe it helps you.

Code: Select all

{#settemp -name ##orderd_on -content {#formcalendar -f dd/mm/yyyy -head Select ordered on date}}(*
*){#settemp -name ##day_offset -content {#formeditbox -text ± how many days? for delivery -def +5 -single -required}}(*
*){#settemp -name ##due_day -content {#datetime -f dd/mm/yyyy -s {#gettemp ##day_offset}w -value {#gettemp ##orderd_on}}}(*
*){#settemp -name ##days -content {#datecalc -date2 {#gettemp ##due_day} -mode 3}}
-------------------------
Ordered on  - {#gettemp ##orderd_on}
Day offset - {#gettemp ##day_offset}
Due Day -  {#gettemp ##due_day}   <-- "ordered on" plus "x"Tage im offset

{#check -text {#gettemp ##days} -case >= 1 -output should arrive in {#gettemp ##days} days.|== 0 -output should arrive today.|>= -1 -output should have arrived {#check -text  {#gettemp ##days}  -case < 0 -output {#calc {#gettemp ##days} *-1 -round auto}} day ago. -else should have arrived {#check -text  {#gettemp ##days}  -case < 0 -output {#calc {#gettemp ##days} *-1 -round auto}} days ago.}
Gives me the following output:
-------------------------
Ordered on - 18.11.2019
Day offset - +5
Due Day - 25.11.2019 <-- "ordered on" plus "x"Tage im offset

should arrive in 5 days.
-------------------------
Ordered on - 15.11.2019
Day offset - +5
Due Day - 22.11.2019 <-- "ordered on" plus "x"Tage im offset

should arrive in 4 days.
-------------------------
Ordered on - 14.11.2019
Day offset - +5
Due Day - 21.11.2019 <-- "ordered on" plus "x"Tage im offset

should arrive in 3 days.
-------------------------
Ordered on - 13.11.2019
Day offset - +5
Due Day - 20.11.2019 <-- "ordered on" plus "x"Tage im offset

should arrive in 2 days.
-------------------------
Ordered on - 12.11.2019
Day offset - +5
Due Day - 19.11.2019 <-- "ordered on" plus "x"Tage im offset

should arrive in 1 day.
-------------------------
Ordered on - 11.11.2019
Day offset - +5
Due Day - 18.11.2019 <-- "ordered on" plus "x"Tage im offset

should arrive today.
-------------------------
Ordered on - 08.11.2019
Day offset - +5
Due Day - 15.11.2019 <-- "ordered on" plus "x"Tage im offset

should have arrived 1 day ago.
-------------------------
Ordered on - 07.11.2019
Day offset - +5
Due Day - 14.11.2019 <-- "ordered on" plus "x"Tage im offset

should have arrived 2 days ago.

Post Reply