How to add selected days in particular date column

Posted by Karthik2010_Mca under C# on 5/24/2014 | Points: 10 | Views : 441 | Status : [Member] | Replies : 2
Hi,

How to add selected days in particular date column.


Current Output:
Dt_BatchStartDate I_Admission_GraceDays
2014-05-05 00:00:00.000 NULL
2014-05-21 00:00:00.000 10
2014-06-06 00:00:00.000 NULL
2014-06-10 00:00:00.000 5
2014-05-05 00:00:00.000 NULL
2014-05-05 00:00:00.000 30

Expected Output:
Current Output:
Dt_BatchStartDate I_Admission_GraceDays
2014-05-05 00:00:00.000 NULL
2014-05-31 00:00:00.000 10
2014-06-06 00:00:00.000 NULL
2014-06-15 00:00:00.000 5
2014-05-05 00:00:00.000 NULL
2014-06-04 00:00:00.000 30

The below mentioned query getting current output.

SELECT
A.Dt_BatchStartDate ,A.I_Admission_GraceDays
FROM T_Student_Batch_Master A
INNER JOIN T_Center_Batch_Details B
ON B.I_Batch_ID=A.I_Batch_ID
AND B.I_Centre_Id = 767
AND B.I_Status = 4
AND A.AllowOnlineAddmission = 1
INNER JOIN T_Course_Master C
ON C.I_Course_ID= A.I_Course_ID
AND C.I_CourseFamily_ID = 535
AND C.I_Brand_ID = 1
--AND A.Dt_BatchStartDate > GETDATE()
INNER JOIN dbo.T_Delivery_Pattern_Master E
ON A.I_Delivery_Pattern_ID = E.I_Delivery_Pattern_ID
LEFT OUTER JOIN dbo.T_Course_Fee_Plan F
ON B.I_Course_Fee_Plan_ID = F.I_Course_Fee_Plan_ID
ORDER BY C.S_Course_Name


Thanks
Karthik.k

Karthik


Responses

Posted by: Vuyiswamb on: 7/6/2014 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
Use date add like this

--adding 3 days in from the current date
SELECT DATEADD(Day, 3, GETDATE()) AS NewDate


Thank you for posting at Dotnetfunda
[Administrator]

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

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

Up
0
Down

SELECT DATEADD(DAY, ISNULL(A.I_Admission_GraceDays,0), A.Dt_BatchStartDate) AS Dt_BatchStartDate
,A.I_Admission_GraceDays
FROM T_Student_Batch_Master A
INNER JOIN T_Center_Batch_Details B
ON B.I_Batch_ID=A.I_Batch_ID
AND B.I_Centre_Id = 767
AND B.I_Status = 4
AND A.AllowOnlineAddmission = 1
INNER JOIN T_Course_Master C
ON C.I_Course_ID= A.I_Course_ID
AND C.I_CourseFamily_ID = 535
AND C.I_Brand_ID = 1
--AND A.Dt_BatchStartDate > GETDATE()
INNER JOIN dbo.T_Delivery_Pattern_Master E
ON A.I_Delivery_Pattern_ID = E.I_Delivery_Pattern_ID
LEFT OUTER JOIN dbo.T_Course_Fee_Plan F
ON B.I_Course_Fee_Plan_ID = F.I_Course_Fee_Plan_ID
ORDER BY C.S_Course_Name


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

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

Login to post response