ISNULL(DocumentPostingDate, CAST(CONCAT(MaterialDocumentYear, '-12-31') AS Date)) AS DocumentPostingDate

 

SELECT [SourceSystem]
          ,[Client],[MaterialDocumentId],[MaterialDocumentYear],[Line],[MovementType],[MaterialId],[PlantId],[StorageLocationId],[BatchNumber],[StockTypeId],[SpecialStock]
          ,[SupplierId],[CustomerId],[SalesOrderNumberId],[SalesOrderItem],[DeliveryScheduleForSalesOrder],[DebitCredit],[CurrencyId],[AmountLocalCurrency],[ValuationType]
          ,[Quantity],[BaseUnitOfMeasure],[PurchasingDocumentId],[PurchasingDocumentItem],[ReferenceDocumentId],[ReferenceDocumentItem],[DeliveryCompletedIndicator]
          ,[ItemText],[EquipmentNumber],[ShipToPartyId],[UnloadingPoint],[CostCenterId],[ProjectNumberOld],[OrderNumber],[CompanyId],[ReceivingIssuingMaterialId]
          ,[ReceivingIssuingPlantId],[ReceivingIssuingStorageLocationId],[ReceivingIssuingBatch],[ValuationTypeOfTransferBatch],[SpecialStockIndicatorForPhysicalStockTransfer]
          ,[MovementIndicatorId],[MovementTypeForWarehouseManagement],[GLAccountId]

          ,ISNULL(DocumentPostingDate, CAST(CONCAT(MaterialDocumentYear, '-12-31') AS Date)) AS DocumentPostingDate

          ,[DeliveryId],[DeliveryItem],[StgCreateDate],[StgChangeDate]
FROM [VartaDataWarehouse].[fct].[MaterialDocumentSegment]
WHERE SourceSystem = 'M'