web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

Once DateTime field value pass to csv File from x++,'AM','PM' value hiding

(0) ShareShare
ReportReport
Posted on by 240

Hi Team,

I have developed a functionality,to export to csv from x++.while value got expoted,AM/PM value of Time is getting hidden.

1222.csvFile.png

Code Part for csv is

3757.Code1.png

I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    237,961 Most Valuable Professional on at

    If you want to see what exactly you have in the CSV file, open it in a text editor.

    You're confused by the fact that Excel applies formatting - in your case, it seems to be displaying dates in 24-hour format (which doesn't need any AM/PM).

    If you want to see different format in Excel, change the format of the cell. But note that this has nothing to do with CSV - CSV stores just values, nothing else. To keep your formatting, you must save the file as Excel spreadsheet and not a mere text file (= CSV).

  • MATTGUO Profile Picture
    22,349 Moderator on at

    Hi Sanjay,

    If you want to see them in .CSV file, you can change the consiBiReqTable.ExpiryDatetime to datetime2str(consiBiReqTable.ExpiryDatetime).

  • Sanjay kumar singh Profile Picture
    240 on at

    Thanks Martin,
    Once DateTime is exporting to csv,its using custom Format.


    Even in Notepad,its considering 24-hour format.

    CSV-Format.png


    I think third party software during integration, needs to consider 24-hour Format.

  • Martin Dráb Profile Picture
    237,961 Most Valuable Professional on at

    If you're interested in what is inside CSV, stop looking at Excel interpretation of this CSV. These are two different things and if Excel isn't relevant for you, it brings only confusion and no positive value.

    If you need a specific format exported from AX, explicitly converting the datetime value to string using the required format is indeed the right approach.

    You didn't mention any "third party software during integration" before - how is it related to this topic? Are you saying that the CSV isn't what was exported from AX, but it was transformed by another application? Or are you saying that you want to pass the CSV to a third -party application and this application expects 24-hour format? If so, then you don't have any problem, because you're saying that it's what you have in CSV, right?

  • Sanjay kumar singh Profile Picture
    240 on at

    Hi Martin,

    The Data from AX we are exporting to csv(with x++ code),Storing csv files at Azure Blob Container.

    My Functional is expecting those csv File will be consumed by some third party integration(we are guessing).

    Our task is to add ExpiryDateTime in generated csv (which are storing in Blob Container).

  • MATTGUO Profile Picture
    22,349 Moderator on at

    Hi Sanjay,

    If the requirement is not to see AM / PM or a specific format, then the CSV file is enough to complete your task.

  • Sanjay kumar singh Profile Picture
    240 on at

    csvCode.png

    All My efforts(directly sending the field value, or convert to specific string format) are taking value of DateTime as 24- hour Format only.

    I think we need to convince client with 24-hour format only in csv file.

  • Martin Dráb Profile Picture
    237,961 Most Valuable Professional on at

    If I need a specific date/time format, my preferred solution is using .NET. Doing it with native X functions is usually more complicated.

    For example:

    System.DateTime dateTime = DateTimeUtil::utcNow();
    str s = System.String::Format('{0:g}', dateTime);

  • Sanjay kumar singh Profile Picture
    240 on at

    with above code also, it consider 24-hour format.'AM','PM' we can not be able to retain in csv file.

    If manually also we enter  2/27/2020 8:00:00 AM  in a csv file cell, it gets converted into 24-hour format.

  • Martin Dráb Profile Picture
    237,961 Most Valuable Professional on at

    Converted? What are you talking about? If you put a value to file and save the file, the value should be what you put there, right?

    Aren't you again doing the same mistake and confusing visualization in Excel with the context of the CSV file? If so, please look again at beginning of this discussion and correct your approach.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Martin Dráb Profile Picture

Martin Dráb 592 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 478 Super User 2025 Season 2

#3
BillurSamdancioglu Profile Picture

BillurSamdancioglu 305 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans