• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 277
  • Last Modified:

Time manipulation using SQL SP or C#

How can write add hours with a date for the folloiwng case?

Supose today(30/04/2011) we are working from 7am to 3pm and tomorrow is a holiday and after tomorrow(2/05/2011) work starts at 7 and finish 5). if we get a repair work today and need 7 hours to finsih it, we have to add this 7 hours with the current date and time (let's say 10 am now) and it should display the finishing date and time. The remaining working hours need to added with the next work starting hours, if the next day is holiday (eg. Sunday), then the remaining hours should be added with Monday's starting time.

How can I achive it using sql stored procedure or c#?

Please give a sample or good links.

ayha
0
ayha1999
Asked:
ayha1999
  • 2
  • 2
2 Solutions
 
brutaldevCommented:
Because you are using .NET you should go with the TimeSpan class to easily figure out times by performing mathematical calculations on dates. The DateTime objects that you are more than likely using also come with methods to add days/hours etc easily.

Using SQL would be more complicated than using C#. Here is a link with a lot of examples on manipulating dates and times: http://www.techrepublic.com/article/calculate-period-of-time-with-net/5760752
0
 
ayha1999Author Commented:
Could u please give a sample in c# on how do it?

thanks

ayha
0
 
Manoj PatilSr. Software EngineerCommented:
Hello,
Check the following link. It may help you to know more about the Parameter of Date Time....

http://msdn.microsoft.com/en-us/library/system.datetime.aspx#Y114
0
 
Manoj PatilSr. Software EngineerCommented:
0
 
ayha1999Author Commented:
thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now