datetime

SQL server - Select all items with a date on the previous month

Hi Guys, I have a table in my SQL Server database called "items" which has a column called "dateFinished". I have a script that will run on the 1st day of each month which needs to select all items that finished in the previous month. So, for example, on the 1st February it will need to select all items where the dateFinished is great...

.NET DateTime to SqlDateTime Conversion

While converting .NET DateTime (when is default(DateTime)) to SqlDateTime should I always check if the .NET date is between SqlDateTime.MinValue and SqlDateTime.MaxValue [or] Is there a good way to do this. ...

Function to return date of Easter for the given year

So, here's a funny little programming challenge. I was writing a quick method to determine all the market holidays for a particular year, and then I started reading about Easter and discovered just how crazy* the logic is for determining its date--the first Sunday after the Paschal Full Moon following the spring equinox! Does anybody kno...

Refactor for Speed: Convert To a Date

Hello, I work for myself, I am a self-employed coder and as a result I don't have the luxury of code reviews or the ability to improve based upon peer programming. I am going to use this as an exercise to see if the StackOverflow community might help to review a simple method which i've written; internal static DateTime CONVERT_To_D...

String was not recognized as a valid DateTime " format dd/MM/yyyy"

I am trying to convert my string formated value to date type with format dd/MM/yyyy. this.Text="22/11/2009"; DateTime date = DateTime.Parse(this.Text); What is the problem ? It has a second override which asks for IFormatProvider. What is this ? DO I need to pass this also. If Yes how to use it for this case Edit What is t...

Convert Chrome history date/time stamp to readable format

I originally posted this question looking for an answer with using python, got some good help, but have still not been able to find a solution. I have a script running on OS X 10.5 client machines that captures internet browsing history (required as part of my sys admin duties in a US public school). Firefox 3.x stores history in a sqlit...

how to convert date in oracle

I have a date in the format of: 27-MAY-09 12.00.00.000000 AM I want to convert it to: 05/27/2009 I did to_char(my_date_variable, 'MM/DD/YYYY') however that gives me character to number conversion error what can I do to convert this date? my_date_variable is declared as: my_date_variable VARCHAR2(40); ...

Trying to parse String to DateTime into format "02/01/2010" dd/MM/yyyy rather than "1/2/2010 MM/dd/yyyy

I am trying to convert a string into date time format. DateTime.Parse(tempfrmBankDetails.dgvBankDetails.SelectedRows[0].Cells["PaymentDate"].Value.ToString(),null); This is printed as an output but i want it in dd/MM/yyyy format. How should i parse it {1/2/2010 12:00:00 AM} EDIT I have created a custom control which accepts s...

Convert DateTime to yyyyMMdd int

What is the quickest way to convert a DateTime to a int representation of the format yyyyMMdd. i.e. 01-Jan-2007 --> 20070101 (as in int)? ...

ADO.NET Update command with datetime parameter issue

Hi, I am trying do a database update via stored procedure using ADO.NET. Basically i setup all the parameter and command and have the one of the parameter set like the following DbParameter nm8 = provider.CreateParameter(); nm8.ParameterName = "@EDITDATE"; nm8.DbType = System.Data.DbType.DateTime; nm8.Value = aObject.ADateTime; comman...

How can I print a datetime in the xs:dateTime format in Perl?

I would like to take a time stamp (e.g. 1263531246) and convert it to a string representation suitable for output to an XML file in an attribute field conforming to xs:dateTime. xs:dateTime expects something like: 2002-05-30T09:30:10-06:00 Ideally, I would use the form of output that includes offset from UTC (as above). In this projec...

Using Lambda expressions to order a list by GMT date

I have a list that contains dates that are in GMT format. What is the most elegant way to ensure that the following Lambda expression orders on the date field as GMT? ProductsList.OrderBy(Product => Product.Added).ToList(); ...

PHP strtotime() looks like it is expecting a Euro format

I've been using PHP's strtotime() method to accept a date field on a form. I love how powerful it is, in how it will accept "Tomorrow", "Next Thursday", or (supposedly) any date representation and convert it to the Unix timestamp. It's been working great -- until yesterday. Someone entered "2-4-10" and instead of logging Feb 4th, 2010, ...

COM - How to convert DATE data type to a formatted string in UTC

How to convert DATE data type to a formatted string in UTC without using the library class COleDateTime. I do not have ATLComTime.h on my system I would like to pass it as a DATE data type and return a string in 'yyyy-mm-ddThh:mm:ssZ' ...

DateTime Comparison in LINQ

I am ran into the following issue. Take a look at the following where clause. Where(x => x.CreateTS <= dateParameters.CreationDate.ToDateValue && x.CreateTS >= dateParameters.CreationDate.FromDateValue) CreateTS is a Timestamp column in the table. so when my dateparameters are todate = 01/28/2010 12:00A.M" fromdate= "01/2...

Changing the hour with datetime.replace() in python

Given that foo is a valid datetime object in python, One can change the hour represented in a datestamp (foo) by doing something something like: foo2 = foo.replace( hour=5 ) Rather then replacing the hour with a particular value ( as is done above )..is it possible to increment the time in foo by say, 5 hours ? Something along the...

Age from birthdate in python

How can I find an age in python from today's date and a persons birthdate? The birthdate is a from a DateField in a Django model. ...

django new field generating "global name...is not defined" error

Hello, In a django app, I have models for a Word (to be learned), a Student (learning it), and StudentWord is a table to handle the many to many relationship: class Word(models.Model): word = models.CharField(max_length=80) image = models.ForeignKey(Image) language = models.ForeignKey(Language) def __unicode__(self): ...

What are good reasons to choose TIMESTAMP over DATETIME columns in MySQL?

Disclaimer: This might be a duplicate of datetime vs. timestamp?, but I feel I am not convinced of the answers: My question is: What are the good reasons to choose TIMESTAMP over DATETIME columns in MySQL? I'm pretty sure I don't know everything there is about the differences between those two, so I will try to list the main advantages...

Wrong week number using DATEPART in SQL Server

I've got the problem that select datepart(ww, '20100208') is returning as result week 7 in SQL Server 2000. But 08.02.2010 should be week 6 according to the ISO 8601 specification! This is causing problems in delivery week calculations. What should I do to get week number values according to ISO 8601? ...