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"
Asked
Active
Viewed 837 times
1

data_henrik
- 16,724
- 2
- 28
- 49

Ala Garali
- 11
- 5
-
How is the variable $date set? Are you using @sys-date? – data_henrik Aug 10 '18 at 10:11
-
yes using @sys-date – Ala Garali Aug 10 '18 at 10:25
-
@sys-date.reformatDateTime('E') ==> it return ('E'). maybe reformatDateTime works only with the English language – Ala Garali Aug 10 '18 at 10:27
1 Answers
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
-
-
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
-