1

I am stucking in sql statement . Please my query below

select 
                               

 master_brand.BRAND_NAME as AcCompanyID, 
                                    lewre_product.SKU_CODE as AcStockID,
                                    lewre_product.SKU_CODE as BarCode,
                                    lewre_product.SKU_CODE as StockBarCode,
                                    lewre_product.SKU_CODE as StockDescription1,
                                    NULL as StockDescription2,
                                    lewre_project.PROJECT_NAME as AcStockBrandID,
                                    lewre_artice.ARTICLE_NUMBER as AcStockGroupID,
                                    icenter_acStockCategory.CATEGORY_CODE as AcStockCategoryID,
                                    icenter_acStockColor.AcStockColorID as AcStockColorID,
                                    lewre_product.SIZE as AcStockSizeID,
                                    'NA' as ISBN,
                                    master_product_type.UOM as AcStockUOMID,
                                    lewre_article_price.FINAL_COST as StockCost,
                                    lewre_article_price.PRICE as StockPrice1,
                                    0 as StockPrice2,
                                    0 as StockPrice3,
                                    0 as StockPrice4,
                                    0 as StockPrice5,
                                    lewre_artice.CREATE_DATE
        
                          

 from [LEWRE.ARTICLE]as lewre_artice,
                                 [iCENTER.ACSTOCKCATEGORY]  as icenter_acStockCategory,
                                 [iCENTER.ACSTOCKCOLOR] as icenter_acStockColor,
                                 [LEWRE.PRODUCT] as lewre_product,
                                 [MASTER.BRAND] as master_brand,
                                 [LEWRE.PROJECT] as lewre_project,
                                 [MASTER.PRODUCT_TYPE] as master_product_type,
                                 [LEWRE.ARTICLE_PRICE] as lewre_article_price
         

                     

   where
                                (icenter_acStockCategory.CATEGORY_ID = lewre_artice.PRODUCT_CATEGORY_ID
                             AND icenter_acStockCategory.PRODUCT_TYPE_ID = lewre_artice.PRODUCT_TYPE_ID)
                             AND lewre_product.ARTICLE_ID = lewre_artice.ARTICLE_ID
                             and lewre_product.COLOR_ID = icenter_acStockColor.COLOR_ID
                             and master_brand.BRAND_ID = lewre_artice.BRAND_ID
                             and lewre_artice.PROJECT_ID = lewre_project.PROJECT_ID
                             and master_product_type.PRODUCT_TYPE_ID = lewre_artice.PRODUCT_TYPE_ID
                             and lewre_artice.ARTICLE_ID = lewre_article_price.ARTICLE_ID
                             and lewre_artice.CREATE_DATE 
                     
                             
                             
                             order by lewre_artice.CREATE_DATE
                                 

Here is the result that i get

enter image description here

I want to select all row which create_date is current date.for example (2012-04-30)' . How can i get the result? Please help me

4

1 に答える 1

2

これを where 句に追加します。

  lewre_artice.CREATE_DATE >= cast(getdate() as date) and 
  lewre_artice.CREATE_DATE < cast(dateadd(day, 1, getdate()) as date)

getdate()現在のタイムスタンプを返し、cast(getdate() as date)時間部分を削除します。dateadd(day, 1, ....)1日追加します。比較はCREATE_DATE、間隔内にある行を返します。

于 2012-04-30T09:10:42.567 に答える