By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,379 Members | 1,380 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,379 IT Pros & Developers. It's quick & easy.

Required Data between two dates

P: 42
I want to show the data between two dates.The date format is like this 2008-06-10 14:49:57.577
Jun 11 '08 #1
Share this Question
Share on Google+
2 Replies

Expert 100+
P: 1,134
check out the "between" statement in the help files
Jun 11 '08 #2

Expert 100+
P: 692

You can write sql query like this to get the records between 2 dates :

--Date variables
Declare @vdate1 varchar(50);
Declare @vdate2 varchar(50);

set @vdate1 = getdate(); --todays date
set @vdate2 = getdate()+100; -- date after 100 days

--Sql statement to compare 2 dates

WHERE (CONVERT(varchar,DateColumn,style) >= @vdate1 AND
CONVERT(varchar,DateColumn,style) <= @vdate2)

In the above example , Convert function is used for converting the DateColumn value into required datetime format.

Hope this is what you require.
Jun 12 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.