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, ...
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

I have the same question (0)

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 544 Most Valuable Professional

#2
André Arnaud de Calavon Profile Picture

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

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 250 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans