DateTimeToDate display format

General question about the package, problems, solutions
edpmvl
Posts: 10
Joined: Mon Jun 20, 2011 3:17 pm

DateTimeToDate display format

Postby edpmvl » Mon Jun 20, 2011 3:24 pm

When i use the DateTimeToDate function the date is returned in yyyy-mm-dd format. I would like to display dd-mm-yyyy in the notifications i send to the customer. I have been trying to find out how this is done, but haven´t found an answer yet. Can i get some help please ? :?

Pavel
Posts: 281
Joined: Fri Dec 12, 2008 12:19 am

Re: DateTimeToDate display format

Postby Pavel » Mon Jun 20, 2011 5:10 pm

edpmvl wrote:When i use the DateTimeToDate function the date is returned in yyyy-mm-dd format. I would like to display dd-mm-yyyy in the notifications i send to the customer. I have been trying to find out how this is done, but haven´t found an answer yet. Can i get some help please ? :?


You can define your own function (submit UDB_property record) to return date in desirable format.
For example, the following fragment would return current date as dd-mm-yyyy

Code: Select all

 
  my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) = localtime(time());
  return sprintf("%2.2d-%2.2d-%4d", $mday, $mon + 1, $year + 1900);   


You can use EN_DateTimeToTimestamp to convert ClearQuest date/time field value to timestamp
The following function can take date/time field or value as a parameter and convert it to dd-mm-yyyy

Code: Select all

 
  my ($date_time) = @_;
  my ($sec, $min, $hour, $mday, $mon, $year, $wday, $yday, $isdst) =      localtime(EN_DateTimeToTimestamp($date_time));
  return sprintf("%2.2d-%2.2d-%4d", $mday, $mon + 1, $year + 1900);   


Regards,
Pavel

edpmvl
Posts: 10
Joined: Mon Jun 20, 2011 3:17 pm

Re: DateTimeToDate display format

Postby edpmvl » Tue Jun 21, 2011 7:49 am

I used the code with EN_DateTimeToTimestamp conversion and it works like a charm. Thank you so much !


Return to “Email Notification Package Q&A”

Who is online

Users browsing this forum: No registered users and 1 guest

cron