LAE

Welcome to the LAE community!  Please feel free to start a discussion in the discussion tab or join in a conversation.

Discussions

Members

Resources

Events

 View Only
  • 1.  Date Output - Formatting Incorrectly

    Employee
    Posted 04-18-2016 06:16

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: tessam

    Hey All,

    I am working on a graph which needs the output to contain a specific date format (MM/DD/YYYY). In LS, I have been able to put together the format correctly:

    dateFieldAsString = format("%02d/%02d/%04d",'Ord Activity Date'.month(),'Ord Activity Date'.day(),'Ord Activity Date'.year())

    However, when I output into an xlsx file, the date appears as such: YYYY-MM-DD. If you click on a cell with a date, you can view the correct format in the formula bar (MM/DD/YYYY).

    A colleague of mine and I put our heads together and set up a template to try and hold the correct view of the date. That, unfortunately, is not working and the date continues to appear as YYYY-MM-DD. The formula bar continues to show the correct format.

    Anyone have any issues with this before? Were you able to resolve this?


  • 2.  RE: Date Output - Formatting Incorrectly

    Employee
    Posted 04-18-2016 07:38

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: ltolleson

    Tessa,

    I was able to test the behavior you are talking about and I believe I am getting the results you want. When you create the dateFieldAsString variable are you outputting that variable?

    In my example below the input date field is called 'MyDate'. This field is then converted into a variable called dateFieldAsString. If you want to view the results of the variable you will need to emit the variable.

    In the attached Excel image the MyDate column shows the format YYYY-MM-DD, but the data is MM/DD/YYYY. This is normal Excel functionality if the field being written is a date type. The dateFieldAsString column shows MM/DD/YYYY because it was written as a string.

    See the coding example below... I also added a couple different variations of how to create the dateFieldAsString output. You used the format command which is good, I just added a couple of variations on how to accomplish the same task.

    
    
    #dateFieldAsString = format("d/d/d",'MyDate'.month(),'MyDate'.day(),'MyDate'.year())
    
    
    #dateFieldAsString = strcat('MyDate'.month(), "/", 'MyDate'.day(), "/", 'MyDate'.year())
    
    
    dateFieldAsString = 'MyDate'.month() + "/" + 'MyDate'.day() + "/" + 'MyDate'.year()
    
    
    
    emit *, dateFieldAsString


    Attachments:
    Excel_DateFormat.jpg


  • 3.  RE: Date Output - Formatting Incorrectly

    Employee
    Posted 04-18-2016 12:21

    Note: This was originally posted by an inactive account. Content was preserved by moving under an admin account.

    Originally posted by: tessam

    Thanks for the info!