Format Datetime in .offline file

 


Below procedure can be used to format Datetime in .offline file when doing customizations. Call this function and it will give you the result mentioned in below format.

e.g: ServiceEngApp-Cust.offline

procedure CGetFormattedDateTime Text {

   parameter DateTime Timestamp;

   variable DateTimeStrVar Text;

   variable YearVar Text;

   variable MonthVar Text;

   variable DayVar Text;

   variable Formatted Text;

   execute {

      call Convert.ToString(DateTime) into DateTimeStrVar;

      call String.RegexSubString(DateTime, "[^T]+", 0, 0) into YearVar;

      call String.RegexSubString(YearVar, "[^-]+") into YearVar;

      call String.RegexSubString(DateTimeStrVar, "-[0-9]{2}-") into MonthVar;

      call String.RegexReplace(MonthVar, "-", "") into MonthVar;

      call String.RegexSubString(DateTimeStrVar, "-[0-9]{2}T") into DayVar;

      call String.RegexReplace(DayVar, "-|T", "") into DayVar;


      set Formatted = [DayVar+"/"+MonthVar+"/"+YearVar];


      if [DateTime = null] {

         set Formatted = null;

      }

      return Formatted;

   }

}


You will get the result in this format: 03/12/2025 


Post a Comment

0 Comments