How to display current date and time in String format in Ax2009?

Hi .

Now i display Date and time like this

SystemDateGet(); = 2014\03\11

currenttime = strFmt(time2str(timeNow(), TimeSeparator::Colon, timeseparator::Colon)); HH:MM:SS

But i need to display both current date and time in string format eg 201403009133435

Pls reply ASAP.

thanks in advance


Am new to dynamics ax 2009. How to convert the datetime to string and display as like above format. pls reply?

Try this in ur Job

date d = today();

str s;


s = date2Str(d, 321, 2, 1, 2, 1, 4);

print “Today’s date time is " + s+” "+ time2str(timeNow(), Timeseparator::Space, TimeFormat::Hour24);


Hi Saadullah,

Thanks, Its working fine. but for year, month , date, hours, mins and seconds in between all space is coming. how to avoid that?

For example you declare timeseperator :: space for time. how to avoid or change that argument to display without space and as well as date.

Thanks once again.

date d = today();

str s, time;


s = date2Str(d, 321, 2, 0, 2, 0, 4);

time = time2str(timeNow(),2, TimeFormat::Hour24);

print "Today’s date time is " + s+substr(time,1,2)+substr(time,4,2)+substr(time,7,2);


Thanks a lot!!!