Showing posts with label DATE. Show all posts
Showing posts with label DATE. Show all posts

Tuesday, November 21, 2017

p EXPORT TO CSV WITH DATE DIRECT JOB X++ : VIKAS MEHTA :MICROSOFT DYNAMICS AX X++ CODE

EXPORT TO CSV DIRECT JOB X++ WITH DATE : VIKAS MEHTA


public static void export2csvInvJourTrans(InventJournalId _invJournalId)
{
    container           con, conHeader;
    InventJournalTrans  invJourTrans;
    InventJournalTable  invJourTable;
    InventDim           invDim;
    CommaIo              io;

    Dialog              dialog;
    DialogField         dlgFileName;
    Filename            csvfileName;
    FileIOPermission    permission;

    int                 recordCount = 0;

    SysOperationProgress exportprogress = new SysOperationProgress();

    #File
    #AviFiles


    ;


    try
    {
        exportprogress.setCaption("Exporting journal lines to CSV file....");
        exportprogress.setAnimation(#AviTransfer);

        // Header Column

        conHeader = ["JournalId","Date","ItemId","Description","LineNum","Site","Warehouse","Location","SerialNumber","OnHand","Counted","Quantity"];

        dialog = new Dialog("Export to CSV");
        dialog.filenameLookupFilter(["Excel Files","*.csv"]);
        dlgFileName = dialog.addField(extendedTypeStr(FilenameSave),"File Name");

        if(dialog.run())
        {
            csvfileName = dlgFileName.value();
            if(csvfileName)
            {
                permission = new FileIOPermission(csvfileName,#io_write);
                permission.assert();

                io = new CommaIo(csvfileName,#io_write);

                io.inFieldDelimiter(',');


                if(!io || io.status() != IO_Status::Ok)
                {
                    throw error("Error in opening file!");
                }

                // Write the header column
                io.writeExp(conHeader);

                invJourTable = InventJournalTable::find(_invJournalId);

                if(!invJourTable.Posted)
                {
                    recordcount = 1;
                    while select * from invJourTrans where invJourTrans.JournalId == _invJournalId
                    {
                         // Create rows
                        invDim   = InventDim::find(invJourTrans.InventDimId);

                        con= [ _invJournalId,
                               date2str(invJourTrans.TransDate,123,-1,-1,-1,-1,-1),
                               invJourTrans.ItemId,
                               invJourTrans.itemName(),
                               invJourTrans.LineNum,
                               invDim.InventSiteId,
                               invDim.InventLocationId,
                               invDim.wMSLocationId,
                               invDim.inventSerialId,
                               num2str(invJourTrans.InventOnHand,1,2,1,0),
                               num2str(invJourTrans.Counted,1,2,1,0),
                               num2str(invJourTrans.Qty,1,2,1,0)
                            ];

                        io.writeExp(con);

                        recordCount++;
                    }
                }


                CodeAccessPermission::revertAssert();


            }
            else
            {
                info("Invalid file name specified!");
            }
        }


    }
    catch(Exception::Error)
    {
        throw error("Erorr in exporting journal lines.");
    }

}


Convert Date to UTCDateTime : DYNAMICS AX X++ CODE

Convert Date to UTCDateTime

static void ConvertDate2DateTime_vm(Args _args)
{
    TransDate       fromDate,toDate;
    TimeZone        tzone;
    UtcDateTime     fDateTime,tDateTime;
    ;
    
    fromDate    = mkDate(01,06,2017);
    toDate        = mkDate(30,08,2017);
    fDateTime   = Global::datetobeginUtcDateTime(fromDate,tzone);
    tDateTime   = Global::datetoendUtcDateTime(toDate,tzone);
    print fDateTime;
    print tDateTime;
 }

AX MICROSOFT DYNAMICS X++ CODE CONVERT DATE TO NUMBER

CONVERT DATE TO NUMBER

date2num(_fromdate))

Thursday, May 4, 2017

DATE FUNCTIONS IN AX 2012 AND AX 2009 : MICROSOFT DYNAMICS AX 2012 :X++ CODE DAY MONTH YEAR TIME ETC

static void date_Functions(Args _args)

{
    Transdate    d;
    ;
  
    d = today();
  
    info(strfmt("Date - %1",d));
  
    //Gets the month for the given date...
    info(strfmt("Month - %1",mthofYr(d)));
  
    //Gets the month name from the given date...
    info(strfmt("Month Name - %1",mthname(mthofYr(d))));
  
    //Gets the day for the given date...
    info(strfmt("Day - %1",dayOfMth(d)));
  
    //Gets the day name from the given date...
    info(strfmt("Day Name - %1",dayname(dayOfMth(d))));
  
    //Gets the year for the given date...
    info(strfmt("Year - %1",year(d)));
  
    //Gets the current weekday number from the date...
    info(strfmt("Weekday number - %1",dayOfwk(d)));
  
    //Gets the day of the year from the given date...
    info(strfmt("Day of year - %1",dayOfyr(d)));
  
    //Gets the week of the year from the given date...
    info(strfmt("Week of the year - %1",wkofyr(d)));
}

MICROSOFT DYNAMICS AX 2012 : SETUP DIFFERENT DATE FORMATS DD/MM/YY OR REGION SPECIFIC ON AX SSRS REPORT

SETUP DIFFERENT DATE FORMATS ON AX SSRS REPORT


Hi

If you want to setup a different Format Date on a SSRS report,

1- Modify date format for all date textbox present in the SSRS Report using the Format function, like =Format(Fields!TransDate.Value, "dd/MM/yyyy")

2- If you want follow the User Timezone, for all date textbox you can use ConvertUtcToAxUserTimeZoneForUser method, like =Microsoft.Dynamics.Framework.Reports.DataMethodUtility.ConvertUtcToAxUserTimeZoneForUser(Parameters!AX_CompanyName.Value, Parameters!AX_UserContext.Value, =Fields!TransDate.Value, "d", Parameters!AX_RenderingCulture.Value)

Tuesday, April 12, 2016

GET DATE IN MICROSOFT DYNAMICS AX 2009 - 2012 DAY OF MONTH

Date functions in AX 2009

static void DATE(Args _args)
{
    Transdate    d;
    ;
  
    d = today();
  
    info(strfmt("Date - %1",d));
  
    //Gets the month for the given date...
    info(strfmt("Month - %1",mthofYr(d)));
  
    //Gets the month name from the given date...
    info(strfmt("Month Name - %1",mthname(mthofYr(d))));
  
    //Gets the day for the given date...
    info(strfmt("Day - %1",dayOfMth(d)));
  
    //Gets the day name from the given date...
   info(strfmt("Day Name - %1",dayname(dayOfwk(d))));
  
    //Gets the year for the given date...
    info(strfmt("Year - %1",year(d)));
  
    //Gets the current weekday number from the date...
    info(strfmt("Weekday number - %1",dayOfwk(d)));
  
    //Gets the day of the year from the given date...
    info(strfmt("Day of year - %1",dayOfyr(d)));
  
    //Gets the week of the year from the given date...
    info(strfmt("Week of the year - %1",wkofyr(d)));
}

Related Posts Plugin for WordPress, Blogger...