1

How to extract day from date in watson conversation. The language is French.
I would like if $day=="Samedi" (in English => Saturday) or $day=="Dimanche" (in English => Sunday), the respond is "We do not work Saturday and Sunday"

data_henrik
  • 16,724
  • 2
  • 28
  • 49
Ala Garali
  • 11
  • 5

1 Answers1

0

Use the reformatDateTime('u') to return the day of the week index. Then you can check for day 6 or 7. That would be even language-independent. The documentation for SimpleDateFormat indicates that the parameter should be F, not u to retrieve the index. Thus, you may want to experiment.

data_henrik
  • 16,724
  • 2
  • 28
  • 49
  • I used @sys-date.reformatDateTime('u') and @sys-date.reformatDateTime('F') and @sys-date.reformatDateTime('E') and all of them return the letter 'u' or 'F' or 'E' – Ala Garali Aug 10 '18 at 10:57
  • I find the solution: in json editor ==> { "context": { "date": " @sys-date.reformatDateTime('EEEEE') ?>" } } – Ala Garali Aug 10 '18 at 11:29
  • That returns what? I would add that to the answer. – data_henrik Aug 10 '18 at 11:44
  • I used in json editor : { "context": { "date": " @sys-date.reformatDateTime('EEEEE') ?>", "date_rdv": "@sys-date", "date_formate": " @sys-date.reformatDateTime('dd/MM/yyyy') ?>" } } For example: user input = 13 Août 2018 (13 August 2018) $date = "Lundi" (Monday) $date_rdv = "2018-08-13" $date_reformate = "13/08/2018" – Ala Garali Aug 10 '18 at 16:03
  • Why not use the index? It is language-independent. – data_henrik Aug 10 '18 at 16:39