I have got user entered Datetime fields like CreatedON
and CreatedEND
and these are having datetime formats like (29-02-2013) and (12-04-2013) (these are sample values only)
I have got one column in sql server like CreatedDatetime
and values like this 2013-09-03 and 2013-02-03 (these are sample values only)
Now I need to check whether the CreatedDatetime field is in between CreatedON
and CreatedEND
two given dates...
How can i compare the date coming from database with these two values.. this comparison need to be done in sql server only
Would any one suggest any ideas and solutions for this .. Many thanks 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 to datetime.
If user entering a date from another system/program then use parameters:
But if values are already stored in database then just compare fields as
Or if they stored as string(dd-mm-yyyy) then:
You can try using CAST like this:-