String to time format but how?

I want to change a value from int or string format to datetime format. There is any function in SQL like the following?:

    Function:                        Result            

    TimeAdd( nextrundate,"sec",45)   00:00:45
    TimeAdd( nextrundate,"min",45)   00:45:00
    TimeAdd( nextrundate,"hour",4)   04:00:00


    TimeAdd( nextrundate,"min",70)   01:10:00
    TimeAdd( nextrundate,"min",190)  03:10:00

Is there a method that does this in C# also?


You mean:

  • TimeSpan.FromSeconds(double)
  • TimeSpan.FromMinutes(double)

see MSDN:

System.TimeSpan s = new TimeSpan();
s.Add(new TimeSpan(days, hours, minutes, seconds, milliseconds))

In SQL you could use something like

convert(varchar(8),dateadd(second,45,nextrundate),114) convert(varchar(8),dateadd(minute,45,nextrundate),114) convert(varchar(8),dateadd(hour,4,nextrundate),114)

In C# you can use the DateTime and TimeSpan classes.

DateTime rundate = DateTime.Now();
DateTime nextRunDate= rundate .AddDays(1);
TimeSpan oneDay=(TimeSpan)(nextRunDate-rundate);

There are similar methods for minutes, seconds etc.

DateTime d = new DateTime(); d = d.AddMinutes(70); Console.WriteLine(d.ToString("yyyy-MM-dd HH:mm:ss"));

DateTime d = new DateTime();
d = d.AddMinutes(70);
Console.WriteLine(d.ToString("yyyy-MM-dd HH:mm:ss"));

Need Your Help

Drawn string (using drawString) flickers

java swing graphics

I'm doing this project here, and I have to draw a string to prevent me some problems, the drawing works and the string updates just fine, thing is, it tends to flicker somehow. It's like it's being

Open a form to a specific tab

vba ms-access

Having great difficulty getting this to work, When a button is pressed I want to open a form at a specific tab.

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.