| Author |
Topic |
|
eugz
Posting Yak Master
210 Posts |
Posted - 2009-10-07 : 16:19:21
|
Hi all.I would like to create select that display me range of the date from current date to last previuos month. select distinctFName,LName,convert(varchar(10),AppointmentDate,101)AppointmentDatefrom Appointment How to modify that select to get all appointments for the last 2 month.Thanks. |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-10-07 : 16:29:11
|
That select is to modify in the not shown rest of the statement. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2009-10-07 : 16:41:50
|
addWHERE AppointmentDate >= dateadd(m,-2,getdate())to your query. No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
eugz
Posting Yak Master
210 Posts |
Posted - 2009-10-07 : 17:46:59
|
| How to create function that get me result date like 2 month early from appointment date?Thanks. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-10-08 : 02:35:54
|
quote: Originally posted by eugz How to create function that get me result date like 2 month early from appointment date?Thanks.
Why do you want to create a function for this?Just use it in WHERE clauseMadhivananFailing to plan is Planning to fail |
 |
|
|
eugz
Posting Yak Master
210 Posts |
Posted - 2009-10-08 : 09:32:09
|
I would like to create SP likeprocedure [dbo].[sp_Appointments](@AppointmentDate as datetime)asselectAppointment_id,FName,LName,convert(varchar(10),AppointmentDate,101)AppointmentDate,AppointmentDateFromfrom Appointment where AppointmentDateFrom I would like to get on 2 month early date then AppointmentDate.Thanks. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-10-08 : 10:08:36
|
| procedure [dbo].[sp_Appointments](@AppointmentDate as datetime)asselectAppointment_id,FName,LName,convert(varchar(10),AppointmentDate,101)AppointmentDate,AppointmentDateFromfrom AppointmentWHERE AppointmentDate >= dateadd(m,-2,@AppointmentDate )MadhivananFailing to plan is Planning to fail |
 |
|
|
eugz
Posting Yak Master
210 Posts |
Posted - 2009-10-08 : 10:24:57
|
| Thanks a lot for help. It works exactly like I expected. Thank you very much. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2009-10-08 : 10:31:33
|
quote: Originally posted by eugz Thanks a lot for help. It works exactly like I expected. Thank you very much.
You are welcome MadhivananFailing to plan is Planning to fail |
 |
|
|
|