Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE

Pixel Perfect Date Formatting when Date Field Used as a Level

No ratings
cancel
Showing results for 
Search instead for 
Did you mean: 
Frank_S
Support
Support

Pixel Perfect Date Formatting when Date Field Used as a Level

Last Update:

Jul 6, 2021 8:39:20 AM

Updated By:

Sonja_Bauernfeind

Created date:

Jun 1, 2017 3:33:45 PM

When a date field is used for or inside a Level in Pixel Perfect, the output may not be interpreted as expected.

You expect to see something like: 2017/05/31

You actually see: yyyy/MM/dd


Environment:

 

This is the expected behavior of the underlying DEV Express platform upon which Pixel Perfect is designed

 

Resolution:


To resolve this, you need to perform some scripting on the 'date' field within the Pixel Perfect editor.
 
The scripting involves the following steps.

  1. Set up your Pixel Perfect report with a 'level'
  2. Drop your 'date' field into the template editor inside the level
  3. Click on the 'date' field
  4. Click the Scripts button in the Template Editor top right corner
  5. Next choose the 'before print' drop down option
  6. Insert the following code:
    private void label1_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) {
          XRLabel label = (XRLabel)sender;
        double x = Convert.ToDouble(label.Text);
        DateTime myDate = DateTime.FromOADate(x);
        label.Text=myDate.ToString("dd/MM/yyyy");
    }​
  7. Click 'Validate' to accept the new line of code (note that you may need to use case sensitivity for MM and dd and or yyyy)
  8. Deselect the 'Scripts' button on the top left corner of the template editor
  9. Preview your report
 
Labels (2)
Comments
Lauri
Specialist
Specialist

I'm grappling with this date issue with Levels in PixelPerfect, and the script solution isn't working, nor is wrapping the field with Text() in Sense. Hoping there's a newer solution... Using NPrinting May 2021 and Sense November 2021.

Sonja_Bauernfeind
Digital Support
Digital Support

Hello @Lauri 

I would recommend posting what you are having a challenge with in our NPritning Discussion forums. This way you can make use of our active community and support engineers monitoring the forums.

All the best,
Sonja 

Contributors
Version history
Last update:
‎2021-07-06 08:39 AM
Updated by: