How to compare two given dates with date coming from datetime field in sql server -
i have got user entered datetime fields createdon
, createdend
, these having datetime formats (29-02-2013) , (12-04-2013) (these sample values only)
i have got 1 column in sql server createddatetime
, values 2013-09-03 , 2013-02-03 (these sample values only) need check whether createddatetime field in between createdon
, createdend
2 given dates...
how can compare date coming database these 2 values.. comparison need done in sql server only
would 1 suggest ideas , solutions .. many in advance..
edit :
declare @return_value int exec @return_value = [dbo].[tp_selecttransactionhistorysearch] @offsetrowno = 1, @fetchrowno = 1, @statusselection = n's', @isreviewed = null, @projectcasenumber = null, @costpagenumber = null, @transactiontypechange = null, @descriptionchange = null, @trasactioncreateonbegindate = n'19-03-2013', @transactioncreatedonenddate = n'20-03-2013', @transactionupdatedonbegindate = n'10-04-2013', @transactionupdateonenddate = n'11-04-2013', @itemid = null select 'return value' = @return_value go
error : msg 8114, level 16, state 5, procedure tp_selecttransactionhistorysearch, line 0 error converting data type nvarchar datetime.
you can try using cast this:-
(createddatetime >= cast(createdon date)) , (createddatetime < cast(createdend date))
Comments
Post a Comment