select eomonth( getdate(), -1 ) select eomonth( getdate() ) select eomonth( getdate(), 1 )Output:
---------- 2019-02-28 (1 row(s) affected) ---------- 2019-03-31 (1 row(s) affected) ---------- 2019-04-30 (1 row(s) affected)
Microsoft AX 2012, X++, C#, SQL server, SSRS, Java, JavaFX, Oracle, PL/SQL, Delphi - codes examples, step-by-step tutorials, experiences.
select eomonth( getdate(), -1 ) select eomonth( getdate() ) select eomonth( getdate(), 1 )Output:
---------- 2019-02-28 (1 row(s) affected) ---------- 2019-03-31 (1 row(s) affected) ---------- 2019-04-30 (1 row(s) affected)
var
iCount : integer;
pBookmark : TBookmark;
pDataSetSource : TDataSet;
begin
...
Screen.Cursor := crHourGlass;
iCount := 1;
pBookmark := pDatasetSource.GetBookmark;
pDatasetSource.DisableControls;
try
pDatasetSource.First;
while not pDatasetSource.Eof do
begin
try
{ action with record }
finally
inc( iCount );
pDatasetSource.Next;
end;
end;
finally
pDatasetSource.GotoBookmark( pBookmark );
pDatasetSource.EnableControls;
Screen.Cursor := crDefault;
end;
var
i : integer;
pColumn : TcxGridDBColumn;
begin
...
for i := 0 to pGridView.VisibleColumnCount - 1 do
begin
pColumn := TcxGridDBColumn( pGridView.VisibleColumns[i] );
ShowMessage( pColumn.DataBinding.FieldName + ' , ' +
GetEnumName( TypeInfo(TFieldType),
ord( pColumn.DataBinding.Field.DataType ) ) );
end;
...
Output:postJournal.menuItemName( menuitemActionStr( InventJournalPostMovement ) );
public class ParamWrapperInt {
public int value;
}
2) Use it:private boolean methodName( ParamWrapperInt _maxMinorDimension ) {
...
/* work with int */
_maxMinorDimension.value = ...
...
return true;
}
List list = new List( Types::String ); ListEnumerator listEnumerator; int iCounter; ... /* split field custVendExternalItem.Description */ list = strSplit( custVendExternalItem.Description, "/" ); listEnumerator = list.getEnumerator(); iCounter = 1; while ( listEnumerator.moveNext() ) { if ( iCounter == 1 ) tmpTable.PO_number = listEnumerator.current(); if ( iCounter == 2 ) tmpTable.revision = listEnumerator.current(); iCounter++; }
/* now() */ LocalDateTime dateNow = LocalDateTime.now(); System.out.println( dateNow ); System.out.println( dateNow.format( DateTimeFormatter.ofPattern( "dd.MM.yyyy H:m:s" ) ) ); /* defined datetime 1. Jan 2018 17:00 h */ LocalDateTime date = LocalDateTime.of( 2018, 1, 1, 17, 0, 0 ); System.out.println( date.format( DateTimeFormatter.ofPattern( "dd.MM.yyyy H:m:s" ) ) ); /* ..add 25 minutes to previous */ LocalDateTime dateend = date.plusMinutes( 25 ); System.out.println( dateend.format( DateTimeFormatter.ofPattern( "dd.MM.yyyy H:m:s" ) ) ); /* ..and check difference in minutes */ System.out.println( date.until( dateend, MINUTES ) );Output:
2018-11-28T09:50:58.724 28.11.2018 9:50:58 01.01.2018 17:0:0 01.01.2018 17:25:0 25
var
pMemTable : TFDMemTable;
pQuery : TFDQuery;
begin
...
pMemTable := TFDMemTable.Create( self );
pMemTable.CloneCursor( pQuery );
...
var
pMemTable : TFDMemTable;
pQuery : TFDQuery;
begin
...
pMemTable := TFDMemTable.Create( self );
pMemTable.FieldDefs.Add( 'key', ftString, 25 );
pMemTable.FieldDefs.Add( 'value', ftString, 25 );
pMemTable.CreateDataSet();
...
pMemTable.AppendRecord( [ 'firstkey', 'firstvalue' ] );
...
type
TEachRowProcedures = class
public
class procedure ExportAsHTML_Proc( ARowIndex: Integer; ARowInfo: TcxRowInfo );
end;
Call as:...
_pView.DataController.ForEachRow( true, TEachRowProcedures.ExportAsHTML_Proc );
=IIf(Fields!ID_week.Value=DATEPART(DateInterval.WeekOfYear, Today()), "LimeGreen","Tomato")
select prodid, fromdate, fromtime, todate, totime from prodroutejob where prodid = '18-044906' and jobtype = 4;..and this result:
prodid fromdate fromtime todate totime -------------------- ----------------------- ----------- ----------------------- ----------- 18-044906 2018-10-08 00:00:00.000 42933 2018-10-08 00:00:00.000 53735 18-044906 2018-10-09 00:00:00.000 31905 2018-10-09 00:00:00.000 39106 18-044906 2018-10-10 00:00:00.000 46033 2018-10-10 00:00:00.000 53234 (3 row(s) affected)How to get difference between FROM and TO in hours ?
select datediff( hour, [start], [end] ) from ( select dateadd( second, a.fromtime, a.fromdate ) as [start], dateadd( second, a.totime, a.todate ) as [end] from prodroutejob a where a.prodid = '18-044906' and a.jobtype = 4 ) aOutput:
diff ----------- 3 2 2 (3 row(s) affected)
select a.* from ( select itemid, namealias, ( select count(*) from docuref where typeid = 'PictureDB' and reftableid = 175 and refrecid = a.recid ) as count_ from inventtable a where itemid like 'S-653-%' or itemid like 'S-697-' or itemid like 'S-698-' ) a where count_ = 0 order by a.itemidOutput could be:
itemid namealias count_ ---------------------------------------- -------------------- ----------- S-653-000-0001 AIDA ALBERT 792 0 S-653-000-0008 AIDA AJA 5006024259 0 S-653-000-0009 AIDA AVISA5006024257 0
select getdate(), datepart( wk, getdate() )
Output: ----------------------- -----------
2018-10-04 06:32:01.717 40
(1 row(s) affected)
0-0_0_0200;R-IVECO FRANCIE, 57M 0-0_0_2500;KOSTRY/8019-57 MIST 0-00260-X-0_0_0000;PODPĚR. TRUBKA PRAVÁFor storing is used memory table (TdxMemTable, QData):
procedure TFDrawingImportItems.doReading; var f : TextFile; sRow : string; aSplitted: TArray< string >; begin { -- delete all rows } if QData.Active then begin QData.Close; QData.Open; end; { -- open file and read data (two columns divided by ";") } AssignFile( f, EFileName.Text ); try Screen.Cursor := crHourGlass; QData.DisableControls; reset( f ); while not eof( f ) do begin readln( f, sRow ); { only two columns } aSplitted := sRow.Split( [';'], 2 ); QData.Insert; QDataItemid.AsString := aSplitted[0]; QDataname.AsString := aSplitted[1]; QData.Post; end; finally closeFile( f ); QData.EnableControls; Screen.Cursor := crDefault; end; end;Output should be:
static void c_Import_AssetSorting( Args _args )
{
SysExcelApplication application;
SysExcelWorkbooks workbooks;
SysExcelWorkbook workbook;
SysExcelWorksheets worksheets;
SysExcelWorksheet worksheet;
SysExcelCells cells;
COMVariantType type;
int row = 1;
str s1, s2;
AssetSorting assetSorting;
/* create excel instance */
application = SysExcelApplication::construct();
workbooks = application.workbooks();
/* try to open excel data */
startLengthyOperation();
try
{
workbooks.open( "c:\\ax\\cz_cpa.xlsx" );
}
catch ( Exception::Error )
{
endLengthyOperation();
error( strFmt( "@CIE269", "c:\\ax\\cz_cpa.xlsx" ) );
return;
}
workbook = workbooks.item( 1 );
worksheets = workbook.worksheets();
worksheet = worksheets.itemFromNum( 1 );
cells = worksheet.cells();
/* go throught excel rows, insert data to table */
ttsBegin;
do
{
s1 = cells.item(row, 1).value().bStr();
s2 = cells.item(row, 2).value().bStr();
//info( s1 + " - " + s2 );
/* TYPE is for testing, if we are at end of data */
row++;
type = cells.item( row, 1 ).value().variantType();
//if ( row > 500 ) break;
if ( !AssetSorting::Exist( s1, AssetSortValue::Sorting2 ) )
{
assetSorting.SortCode = AssetSortValue::Sorting2;
assetSorting.SortingId = s1;
assetSorting.Description = s2;
assetSorting.insert();
}
else info( "Exists - >" + s1 );
}
while ( type != COMVariantType::VT_EMPTY );
ttsCommit;
/* end excel */
application.quit();
info( "OK = " + int2str( row ) );
}
static void job_duplicate_row(Args _args)
{
EmployeeTable_RU tab1, tab2;
tab1 = EmployeeTable_RU::findByEmployeeId( '32' );
if ( !tab1 ) {
info( "Source row not found." );
return;
}
ttsBegin;
/* copy row data from tab1 to tab2 + change two columns values */
tab2.data( tab1 );
tab2.EmployeeId = '463';
tab2.HcmEmployment = 5637145327;
if ( !tab2.validateWrite() ) throw Exception::Error;
tab2.insert();
ttsCommit;
info( "OK" );
}
Get-Process iexploreOutput could be:
Handles NPM(K) PM(K) WS(K) VM(M) CPU(s) Id ProcessName
------- ------ ----- ----- ----- ------ -- -----------
499 46 29208 58308 303 0,45 25512 iexplore
641 54 13280 31924 212 0,31 26804 iexplore
Here is the script for killing of this running processes:# get process (check if exists) $process = Get-Process iexplore -ErrorAction SilentlyContinue # kill it if ( $process ) { echo " -> process found..it will be killed.." $process.Kill() } else { echo " -> process not found.." }Output:
-> process found..it will be killed..
select * from cat where table_name like 'MEN%'Output:
TABLE_NAME TABLE_TYPE ------------------------------ ----------- MENU TABLE MENU_SEQ SEQUENCE MENU_ZAL TABLE
treeView1.Nodes.Clear(); TreeNode parentNode, node; parentNode = treeView1.Nodes.Add( "Parent item" ); node = parentNode.Nodes.Add( "Child item 1" ); node = parentNode.Nodes.Add( "Child item 2" ); node = parentNode.Nodes.Add( "Child item 3" ); treeView1.ExpandAll();Output:
netstat -aon | find "1760"Output:
TCP 127.0.0.1:17600 0.0.0.0:0 LISTENING 7944
DataTable table = new DataTable();
table.Columns.Add(new DataColumn( "Text", typeof( string ) ) );
table.Columns.Add(new DataColumn( "Number", typeof( double ) ) );
table.Rows.Add( new object[] { "Value 1", 1 } );
table.Rows.Add( new object[] { "Value 2", 2 } );
table.Rows.Add( new object[] { "Value 3", 3 } );
dataGridView1.DataSource = table;
Output: if ( isConfigurationkeyEnabled( configurationKeyNum( Retail) ) ) ...