datetime

Convert.ToDateTime , any way to depict month and year fields C# ?

I have the following wonderfully unreliable statement: string LastsuccessfuldownloadDateTime = "04.07.2009 19:21:36" DateTime myDate = Convert.ToDateTime(LastsuccessfuldownloadDateTime); Is it possible to depict the day and month fields explicitly in the conversion? Because my month and day fields are getting swapped.... Thanks ...

Weeknumber print date out

Hallo all. if i have week number 42 and i need to know what dates there are in this week, can sombardy maby tell me a easy way to get this info? tanks a lot :) ...

How to determine time interval during DST transition in C#

I want to compute the time 4 hours later during the DST transition, either into DST or out of it. Currently doing this: DateTime now = DateTime.now(); DateTime later = now.AddHours(4); System.Console.WriteLine(now + " isDST " + now.IsDaylightSavingTime()); System.Console.WriteLine(later + " isDST " + later.IsDaylightSavingTime()); Pr...

SQL statement with datetimepicker

This should hopefully be a simple one. When using a date time picker in a windows form, I want an SQL statement to be carried out, like so: string sql = "SELECT * FROM Jobs WHERE JobDate = '" + dtpJobDate.Text + "'"; Unfortunately, this doesn't actually provide any results because the JobDate field is stored as a DateTime value. I'd l...

how to get TimeZoneInfo short name

Is there any method to get the 3 char code from System.TimeZoneInfo.Local ? e.g. EDT instead of Eastern Daylight time etc. ...

rails time demon in my machine... it eats 2 hours have checked everything!

I have my checked my environment.rb config.time_zone = 'Prague' Nothing in development.rb regarding time This seems to work, in theory... Time.zone.now # Thu, 10 Sep 2009 17:51:35 CEST +02:00 also correct... Time.now # Thu Sep 10 17:52:10 +0200 2009 mysql... SELECT NOW() # 2009-09-10 17:53:48 correct! but when I create a new ...

MS Access selecting records with a variable

We are trying to make a query that has the user enter a date and the query pulls all records according to that date. In the Design View of the query we have tried [Enter Date] in criteria but it will not pull because it will match the date but not time. I have seen lots of dates formatted with ## marks to ignore the time yet I do not kno...

SQL Hurdle - SQL Server 2008

The following query returns the total amount of orders, per week, for the past 12 months (for a specific customer): SELECT DATEPART(year, orderDate) AS [year], DATEPART(month, orderDate) AS [month], DATEPART(wk, orderDate) AS [week], COUNT(1) AS orderCount FROM dbo.Orders (NOLOCK) WHERE customerNumber = @custnum AND...

Comparing if two Date instances refer to the same day

I have two Java instances of java.util.Date and I have to find out if they refer to the same day. I can do this the hard way, taking the dates apart and compare the days, making sure the years match too. Since this is such a common problem, I expect there to be an easier solution to this problem. Thanks! ...

Determining elapsed time

I have two times in PHP and I would like to determine the elapsed hours and minutes. For instance: 8:30 to 10:00 would be 1:30 ...

How to increment DateTime field in SQL Server 2005 by a month?

I have a DateTime field in SQL Server for some products expiration (ExpirationDate). I need to increment all the items manually, and set their expiration a month later than the date stored in the field currently. How can I do that? ...

Simple way to handle time in C#?

My current approach is something like DateTime startHour = new DateTime(1900,1,1,12,25,43); DateTime endHour = new DateTime(1900,1,1,13,45,32); // I need to, say, know if a complete DateTime instance // is later than startHour plus 15 minutes DateTime now = DateTime.Now(); startHour = startHour.addMinutes(15); if (now.CompareTo(new...

php Timestamp working logic

what is exactly happing when creating a Unix Timestamp from a given date. I want the step by step method to create timestamp. (not using php built in functions). EDIT: What is the specialty of this date :) January 1st 1970 00:00 h UTC ...

Natural Language date and time parser for java

Hey guys, I am working on a Natural Language parser which examines a sentence in english and extracts some information like name, date etc. for example: "Lets meet next tuesday at 5 PM at the beach." So the output will be something like : "Lets meet 15/09/2009 at 1700 hr at the beach" So basically, what i want to know is that is ther...

C# best way to compare two time of the day

Hello, I woulld like to know if a specified time of the day is passed. I don't really like the way I am doing : private static readonly TimeSpan _whenTimeIsOver = new TimeSpan(16,25,00); internal static bool IsTimeOver() { return DateTime.Now.TimeOfDay.Subtract(_whenTimeIsOver ).Ticks > 0; } How do you do ? ...

Replace a Date or Time section in a DateTime object in C#

I have a DateTime object which may or may not already contain some date/time information. With that I need to replace the time with my new time independently of the date and vice versa. How would I achieve this? I can't see anything obvious other than creating two new DateTime objects, one with the old/new date and one with the old/new t...

str_to_date for ruby on rails?

so I have to insert a bunch of records from a data source that has dates in the format Sun, Sep 13 1:00 PM. I'm just going to execute SQL that uses STR_TO_DATE But I was wondering in case I need it in the future if you guys know of a way to do this using a ruby method...like a reverse strftime ...

How can I test Perl applications using a changing system time?

I have a web application that I want to run some system tests on, and in order to do that I'm going to need to move the system time around. The application used DateTime all the way through. Has anyone got any recommendations for how to change the time that DateTime->now reports? The only thing that comes to mind is subclassing DateTi...

.NET Greenwich Mean Time

Is there any way to get the date January 1, 1970 Greenwich Mean Time in a datetime? if i just specify new date(1970, 1, 1) i will get it with my current time zone.. ...

ASP.NET C# MVC - Change format for datetime directly on DB or Model

Hello, I'm struggling myself trying to find an easy way to change the DateTime format for my Table field. I have a Model called Article with a field called releaseDate that is a DateTime I managed to do it (visually) by converting the Article.releaseDate.ToString("dd/MM/yy") but the thing is when I try to submit a date with this f...