Click here to Skip to main content
15,885,537 members

How to pass null to a date time filed where i am taking data between fromdate and todate and also based on department,category etc...

Korathu 2 asked:

Open original thread
How to pass null to a date time filed where i am taking data between fromdate and todate and also based on department,category etc....
My query as follows:
SELECT a.AssetId, a.SerialNo, a.ServiceTag, a.CostCenterId, a.AssetStatusId, a.AssetConditionId, a.Description, a.AssetEntryDate, a.RefId, a.RefModule, a.LoginId,
a.StoreStockId, a.AssetNo, a.BarCode, a.AssetPict, a.Notes, i.ItemName, m.Model, it.ItemType, c.CategoryName, b.BrandName, ac.AssetCondition, cc.CostCenter,
CASE WHEN taissue.RefId = 0 THEN 'Not Assigned' WHEN taissue.RefModule = 'D' THEN
(SELECT Department
FROM TblDepartment
WHERE DepartmentId = taissue.RefId) ELSE
(SELECT PersonName
FROM TblPerson
WHERE PersonId = taissue.RefId) END AS [user], ast.AssetStatus, s.PurchaseRate, s.POInfo, s.WarrantyDate, v.VendorName, sm.PurDate, sm.PONo
FROM TblAsset AS a INNER JOIN
TblStoreStock AS ss ON a.StoreStockId = ss.StoreStockId INNER JOIN
TblStock AS s ON s.StockId = ss.StockId INNER JOIN
TblStoreEntryMaster AS sm ON sm.PurchaseId = s.PurchaseId INNER JOIN
TblItem AS i ON s.ItemId = i.ItemId INNER JOIN
TblModel AS m ON m.ModelId = i.ModelId INNER JOIN
TblIemType AS it ON m.ItemTypeId = it.ItemTypeId INNER JOIN
TblCategory AS c ON it.CategoryId = c.CategoryId INNER JOIN
TblBrand AS b ON b.BrandId = m.BrandId INNER JOIN
TblVendor AS v ON s.VendorId = v.VendorId INNER JOIN
TblAssetCondition AS ac ON ac.AssetConditionId = a.AssetConditionId left JOIN
TblAssetStatus AS ast ON ast.AssetStatusId = a.AssetStatusId INNER JOIN
TblCostCenter AS cc ON a.CostCenterId = cc.CostCenterId

LEFT join TblAssetIssueDet tbissue on tbissue.AssetId=a.AssetId
left join TblAssetIssueMst taissue on taissue.IssueId=tbissue.IssueId
left join TblDepartment d on d.DepartmentId=taissue.RefId
where

isnull(@CategoryId,c.CategoryId) = c.CategoryId and
isnull(@BrandID, b.BrandId) = b.BrandId and
isnull(@CondtnId,ac.AssetConditionId) = ac.AssetConditionId and
isnull(@DeptId,d.DepartmentId) = d.DepartmentId
Tags: C# (C# 4.0)

Plain Text
ASM
ASP
ASP.NET
BASIC
BAT
C#
C++
COBOL
CoffeeScript
CSS
Dart
dbase
F#
FORTRAN
HTML
Java
Javascript
Kotlin
Lua
MIDL
MSIL
ObjectiveC
Pascal
PERL
PHP
PowerShell
Python
Razor
Ruby
Scala
Shell
SLN
SQL
Swift
T4
Terminal
TypeScript
VB
VBScript
XML
YAML

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
  4. Don't tell someone to read the manual. Chances are they have and don't get it. Provide an answer or move on to the next question.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the http://www.codeproject.com/info/cpol10.aspx.



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900