Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Unanswered

How to get datetime in file name while exporting to csv in AX 2009

(0) ShareShare
ReportReport
Posted on by

Hi All,

We have written a job to export to csv, able to export if ww dont include datetime in file name.

But when we include the datetime in file name unable to export.

If we include datetime in file name , "file" in the next line is coming as null.

Please  let us know how we can include datetime in the filename while exporting to CSV.

pastedimage1629622984522v1.png

Below is the job:

public static void main(Args _args)
{
Commaio file;
container line;
InventTable inventTable;
LedgerJournalTable ljt;
str filname;
str datefile;
utcDateTime dateTime = DateTimeUtil::getSystemDateTime();
date dateformat;
str TodayDate;
;
dateformat = today();
TodayDate = date2str(dateformat,321,DateDay::Digits2,DateSeparator::Slash,DateMonth::Digits2,DateSeparator::Slash,DateYear::Digits4);
filname = @"C:\\" + TodayDate + "Error.csv";  --> able to get file name with data as "C:\\2021/08/22Error.csv"

#File


file = new Commaio(filname , #io_write);  -->coming null if include date in filename

if( !file || file.status() != IO_Status::Ok)
{
throw error("File Cannot be opened");
}
while select ljt
{
line = [ljt.JournalNum];
file.writeExp(line);

}


}

Regards,

Akbar

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Jonas ”Jones” Melgaard – Community Spotlight

We are honored to recognize Jonas "Jones" Melgaard as our April 2025…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 294,099 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 232,866 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,158 Moderator

Leaderboard

Product updates

Dynamics 365 release plans