datetime

Time calculations with MySQL TIMEDIFF

Hi there, I have the following table: mysql> SELECT id,start1,stop1,start2,stop2 FROM times; +----+---------------------+---------------------+---------------------+---------------------+ | id | start1 | stop1 | start2 | stop2 | +----+---------------------+---------------------+----...

Adding a TimeSpan to a given DateTime

I just want to add 1 day to a DateTime. So I wrote: DateTime date = new DateTime(2010, 4, 29, 10, 25, 00); TimeSpan t = new TimeSpan(1, 0, 0, 0); date.Add(t); Console.WriteLine("A day after the day: " + date.ToString()); I tought the result would be: 2010 04 30- 10:25:00 but I'm still getting the initial date. What's wrong? ...

Creation date column in SQL table

What is the easiest way to automatically fill a datetime column in an SQL data table with the date the row was created? Using SQL Server 2005 if that matters. EDIT: I've tried using GETDATE() for default and that works for an INSERT Query but not when the TableAdapter adds the row. ...

Determine if it has been 6 months since birthday in c#

Hi, Sorry if this is a duplicate, but i think I've seen enough of Google for one day! My application needs to adjust a clients current age by +0.5 if it has been 6 months since their last birthday. The code should look something like this, but how many ticks would there be in 6 months? if (DateTime.Today - dateOfBirth.Date > new Time...

String to Date/Time

I have a serialized DateTime string which looks like this: 2010-04-14T16:32:06.75+10:00 What is the simplest way of deserializing/parsing it back into a DateTime? Edit: Sorry. I was a bit too quick and forgot to add... I'm using C# .Net ...

Calculating time until 1st or 15th of the month in python

I'm trying to write a little budget program in python. This is my first program I'm writing to learn python. The first step is to calculate how many days until either the 1st or 15th (paydays) depending on today's date. Can someone help me out a little? ...

Convert DateTime.Now.Month; as string value

int month=DateTime.Now.Month; It gives output as = 04 But how do I get the month as string 'April' from code behind? ...

exec sp_executesql error 'Incorrect syntax near 1' when using datetime parameter

I have a Ssrs report which sends the following text to the database : EXEC ( 'DECLARE @TeamIds as TeamIdTableType ' + @Teams + ' EXEC rpt.DWTypeOfSicknessByCategoryReport @TeamIds , ' + @DateFrom + ', ' + @DateTo + ', ' + @InputRankGroups + ', ' + @SubCategories ) When I view this in profiler it interprets this as : exec sp_execute...

Datetime string formatting and CultureInfo

I was suprised to see FxCop complaining that I wasn't specifying a CultureInfo in the following: string s = day.ToString("ddd"); Surely the format string param in ToString is completely independent of CultureInfo? Is there any way which CultureInfo could affect the returned string? EDIT: sorry, this is a total fail of a question. It'...

Subtract 1 year from datetime

I have seen a lot of info on how to subtract one datetime from the other and how to add years on to a datetime. but the following is giving me a headache.... When a user inserts a record a hidden field called subdate with a value of datetime.now is added to the db. I then need to have an 'old records' page that lists all the entries th...

sqlite3 date operations when joining two tables in a view?

In short, how to add minutes to a datetime from an integer located in another table, in one select statement, by joining them, in sqlite3? I have a sqlite3 db with: table P(int id, ..., int minutes) and a table S(int id, int p_id, datetime start) I want to generate a view that gives me PS(S.id, P.id, S.start + P.minutes) by joining S....

Extract date from large string

I have string like dhgsf20101211124422asddas. this string contains date in yyyymmddhhmmss formate. How to get that date from long string like above. Thanks in advance ...

VB time input, a better way to do it?

Hello Stack overflow, Working on a handy program for my boss at work as a summer project in between semesters both to make life easier for her, and to practice and improve my skills. Intent is to allow her to quickly and easily calculate the hours and minutes the person worked. The form itself has a series of text boxes for the Clock ...

Rails created_at find condition...

I'm attempting to sum daily purchase amounts for a given user. @dates is an array of 31 dates. I need the find condition to compare a date from the array to the created_at date of the purchases. What I'm doing below compares the exact DateTime for the create_at column. I need it to look at the day itself, not the DateTime. How can I wr...

Convert date, datetime to timestamp

How can I produce a timestamp to millisecond accuracy from a date or datetime in Python? There are an overwhelming number of methods and ways of doing this, and I'm wondering which is the most Pythonic way. ...

Help with DateTime in format I need

I am working with DateTime, trying to get date in the format like this: 03.05.2010-04.05.23 that is: dd.MM.yyyy-HH.mm.ss I'm using DateTime.ParseExact to try to achieve this (maybe wrong) So far I have: var dateInFormat = DateTime.ParseExact(DateTime.Now.ToShortDateString(), "dd.MM.yyyy.HH.mm.ss", null); But can't quite get exactly...

Drupal CCK Date: how to set datetime field's default value to a fix date?

Hi, I have a CCK datetime field and would like to set its default value to 31 May 2011. When I go to the configuration of the field I can set the default value to Now, Blank or Relative. Relative is to be set by a PHP's strtotime argument. However, it fails when I set it to 31 May 2011 --> I get today in the node add form last day of...

Django Date Input Parsing?

I'm trying to get a date for an event from a user. The input is just a simple html text input. My main problem is that I don't know how to parse the date. If I try to pass the raw string, I get a TypeError, as expected. Does Django have any date-parsing modules? ...

sql server datetime

hey i have the following query: select * from table where table.DateUpdated >='2010-05-03 08:31:13:000' all the rows in the table being queried have the following DateUpdated: 2010-05-03 08:04:50.000 it returns all of the rows in the table - even though it should return none. I am pretty sure this is because of some crappy date/t...

I am converting general date to UniversalTime Please tell me how to get this format

i am converting my date to Universal Time using mydate.ToUniversalTime() in vb.net its giving me right time but its giving me time in "5/4/2010 4:30:00 AM" format (in vb.net) but i want it in "Wed, 05 May 2010 05:50:00 GMT" format.. please help me to make it in "Wed, 05 May 2010 05:50:00 GMT" format. value of both date are different so p...