Fetch Record ,Today,Future ,

Posted by Raja_89 under Sql Server on 9/26/2014 | Points: 10 | Views : 454 | Status : [Member] | Replies : 3
Hai
How can i fetch records in future dates based on today's date month basis

Ex:
26.09.14
27.09.14
02.01.2015
25.02.2015
27.10.2015


based on today's date

Regards




Responses

Posted by: Pandians on: 9/27/2014 [Member] [MVP] Silver | Points: 25

Up
0
Down
What DataType do you use to have the Date in your table ?

Cheers
www.SQLServerbuddy.blogspot.com
iLink Multitech Solutions

Raja_89, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Bandi on: 9/29/2014 [Member] [MVP] Platinum | Points: 25

Up
0
Down
hi,

If you have VARCHAR data type for input column, you can do as follows,

--Sample Data Generation
declare @tab table( dates varchaR(100))
insert @tab
SELECT '26.09.14' union all
SELECT '27.09.14' union all
SELECT '02.01.2015' union all
SELECT '25.02.2015' union all
SELECT '27.10.2015'

-- Query to be used
SELECT *, cast(dates as datetime) FROM @tab
where cast(dates as datetime) >= cast(getdate() as date)


Mark This Response as Answer
--
Chandu
http://www.dotnetfunda.com/images/dnfmvp.gif

Raja_89, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naveenhcl on: 9/29/2014 [Member] Starter | Points: 25

Up
0
Down
Hi,

If you want to add days based on today date then you must perform the dateadd function and add the required datatype as well as required days to be added for that.

select dateadd(d, 2,getdate());


The above query is give you todaydate+2 days.

select dateadd(m,2,getdate());


The above query is return todaydate+2 months.

select dateadd(y,2,getdate());


The above query is return todaydate+ 2 years.

Raja_89, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response