cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

HTML Descriptor : compare dates

MRenoud
Super Contributor

Hello,

Is it possible to compare dates in a HTML descriptor ?

 

Is it possible to make a comparison  with day date in a HTML descriptor  ? 

 

We try the code below. It works when 2 dates are the same. It doesn't work when 2 dates are different.

 

For an application object :

[Buffer="Date1,Date2"]

 

[Buffer=Date1 Set][Property="SNCF - Date de début des études"/][/Buffer]
[Buffer=Date2 Set][Property="SNCF - Date de mise hors exploitation"/][/Buffer]


<br>
[Property=Nom/]
<br>
Date 1 :[Buffer=Date1 Get/]
<br>
Date 2 :[Buffer=Date2 Get/]
<br>

[If="Buffer(Date1)=Buffer(Date2)"]
passe1
Buffer(Date1)=Buffer(Date2)

[/If]

<br>
[If="Buffer(Date1)>Buffer(Date2)"]
passe2
Buffer(Date1)>Buffer(Date2)

[/If]

<br>
[If="Buffer(Date1)<Buffer(Date2)"]
passe3
Buffer(Date1)<Buffer(Date2)

[/If]


[/Buffer]

 

I thank you for your help.

Muriel Renoud

 

2 Replies

MRenoud
Super Contributor

Hello,

 

Thank you for your help. We have chosen the first solution. It works fine.

Muriel Renoud

lionel
MEGA
MEGA

Hello Muriel,

I think your problem comes from the fact that your dates are in french format (dd/mm/yyyy).

Since the compare you are using is a string compare... well, it cannot work 😞

There are 2 ways for solving your problem :

 

1 - Use StringFunctions directly in your descriptor

If you do not want or cannot use macros, you'll have to deal with string functions in your descriptor to transform your dates in english format and then compare them. Here is an example :

 

 

[Buffer="Date1FR,Date2FR,Date1US,Date2US"]

[Buffer=Date1FR Set][Property="SNCF - Date de début des études"/][/Buffer]
[Buffer=Date2FR Set][Property="SNCF - Date de mise hors exploitation"/][/Buffer]
[Buffer=Date1US Set]
  [StringFunction=GetRight Length=4][Buffer=Date1FR Get/][/StringFunction]
  [StringFunction=GetMiddle BeginPosition=3 Length=2][Buffer=Date1FR Get/][/StringFunction]
  [StringFunction=GetLeft Length=2][Buffer=Date1FR Get/][/StringFunction]
[/Buffer]
[Buffer=Date2US Set]
  [StringFunction=GetRight Length=4][Buffer=Date2FR Get/][/StringFunction]
  [StringFunction=GetMiddle BeginPosition=3 Length=2][Buffer=Date2FR Get/][/StringFunction]
  [StringFunction=GetLeft Length=2][Buffer=Date2FR Get/][/StringFunction]
[/Buffer]

[If="Buffer(Date1US)=Buffer(Date2US)"]
  passe1
[/If]
[If="Buffer(Date1US)>Buffer(Date2US)"]
  passe2
[/If]
[If="Buffer(Date1US)<Buffer(Date2US)"]
  passe3
[/If]

[/Buffer]

 

 

 

2 - Use a macro

Add the following in your descriptor :

 

 

[ExternalCall Macro=CompareDateApplication/]

 

 

where "CompareDateApplication" is an existing macro coded like this :

 

 

'oObjTarget is the root object of your description (your application in your cased)
'strStringOut is your output string that will be displayed in your descriptor
Public Sub IMegaGenerationTagSolver_TagWrite(strStringIn, oObjTarget, oGenerationContext, strStringOut)
  'Here all the code you need to compare your dates....
  strStringOut = "Your output string.<br> Use <b>html</b> language ! </b>"
End Sub

 

 

 

Regards,

Lionel