Click here to Skip to main content
15,881,092 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i want to put Value in ACompleteDate(Actual Complete Date) Column In My Table. But I am Confuse which Value insert in this column . Any Formula please Suggestion...

My Table Following:-


TaskID int
UserID int
TaskName nvarchar(150)
TaskDesc nvarchar(MAX)
ScriptName varchar(50)
StartDate date
EndDate date
TargatedDays int
ACompleteDate datetime
WorkedDays int
RateID int
RateRemarks nvarchar(50)
Status bit Checked
CreatedBY int
AdminRemarks nvarchar(MAX)
SystemDate datetime
IPAddress varchar(50)
Posted
Updated 2-Dec-14 20:02pm
v2
Comments
Sinisa Hajnal 3-Dec-14 2:04am    
Are you asking US what YOUR program should be doing? At some point, someone will mark the task complete. At that point you set the date to current date. What formula are you expecting? What should actually be in actual date?
Nishant.Chauhan80 3-Dec-14 2:09am    
i want to insert Value in ACompleteDate(Actual Complete Date) Column but which value
Sinisa Hajnal 3-Dec-14 2:22am    
That is exactly what I mean - we can tell you how to insert into the column but you have to know which value should go in there it is your program! Can you describe what should go in there? Why don't you just insert current date when the task is marked complete?
Nishant.Chauhan80 3-Dec-14 2:25am    
No Column already Exist ACompleteDate(Actual Complete Date) Column See On above My Table But How to calculate ACompleteDate(Actual Complete Date) Vs Start Date
Sinisa Hajnal 3-Dec-14 2:32am    
You're not making this any clearer. I know it exists, you're asking how to put value into it. But you never specify WHAT VALUE that is. My comments assume you want to mark the date when the task was actually complete. If you need something else, you have to describe it. What do you mean caclulate vs StartDate. Or to ask differently: If your StartDate is 1.1.2015 and your EndDate is 15.1.2015, what should be ActualDate?

1 solution

When you mark the task as complete, there are two ways you can do it: issue an SQL UPDATE with the current date from the system on which the user decides it is complete:
C#
using (SqlCommand cmd = new SqlCommand("UPDATE MyTable SET ACompleteDate=@DT WHERE TaskID=@ID", con))
   {
   cmd.Parameters.AddWithValue("@ID", taskId);
   cmd.Parameters.AddWithValue("@DT", DateTime.Now);
   cmd.ExecuteNonQuery();
   }

The other alternative is toy use the server time:
C#
using (SqlCommand cmd = new SqlCommand("UPDATE MyTable SET ACompleteDate=GetDate() WHERE TaskID=@ID", con))
   {
   cmd.Parameters.AddWithValue("@ID", taskId);
   cmd.ExecuteNonQuery();
   }

Depends on the environment you want to work in which you want to use.
 
Share this answer
 
Comments
Nishant.Chauhan80 3-Dec-14 2:33am    
thanks a lot sir...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900