datetime

SQL Server 2005: how to subtract 6 month

I have a date, suppose today date declare @d datetime set @d = '20101014' I need select @d - <six month> where is the real number of days that contains last six month, beginning from @d. ...

Parse date with possible single-digit month/day/hour using java.text.SimpleDateFormat

On a project with Talend Open Studio (an Open Source code-generating ETL tool), I am getting errors parsing incoming date strings like "3/14/1967 0:00:00" (note the single-digit month). Digging into the code, I can see it is using java.text.SimpleDateFormat. So the date pattern string I expect I need to use is "d-M-yyyy H:mm:ss"... but ...

SQL Find Holes in Linear Time-Based Table

Hi, I have a linear datetime based table in MySQL and SQL server for a time-based data collection system. There is required to be a new entry in this table that will be timestamped exactly every 10 seconds. Sometimes, the data collection source goes down for a while and comes back up, at which point the newest data is inserted into the...

Why does Perl's DateTime->from_epoch return 1969-12-31 23:59:59?

We are processing data from an API that is returning date/time values of the following form: 1061943540000 When I used the tool on this page it converts the value to the following correct date: Tue Aug 26 2003 17:19:00 GMT-0700 (PDT) We are using the following Perl code to convert the date/time in our script: use DateTime; my $dt ...

call to undefined method DateTime::add method in php

Hello all I am using php 5.2.9 as a part of xampp installation. I am using codeigniter framework for my webapp. When I call upon DateTime::add, the Call to undefined method error is displayed. My code is... $date_now = new DateTime(); $formatted_date = $date_now->format('Y-m-d H:i:s'); $expiry_date = $date_now->add(new DateInterval('P1...

Modify CSV field on import to mysql

I'm trying to import a CSV file to a mysql database. The CSV file contains (amongst other things) dates in the following format: "2010-04-31 17:43:12" My first approach was to use the following .sql script: USE test; LOAD DATA INFILE '/tmp/test.cvs' replace INTO TABLE test_table FIELDS TERMINATED BY ',' LINES TERMINATED BY '\n' (......

C# DateTime problem

Aries March 21 to April 20. Taurus April 21 to May 20. Gemini May 21 to June 21. I need to print the Astrological sign of a user by getting the user's birth month and the date as inputs.how can i get the date range??. EX: March 21 to April 20 ...

datetime problem after deployment of asp.net mvc application

Hi, I have developed the asp.net mvc 2 + C# application. it has create functionality in which there is datetime field. If locally I runs the a application it is working fine . but if i deploys it on IIS server (v 5.1) it, is not accepting date more than 12 (if gives 14/10/2010) will not work), this means it is changing the date format a...

Writing an IsDate() equivalent in C# ?

Apologies if this has been asked before. I have some data which I need to store as strings, some of that data being dates. The data starts off as strings like "01/02/10" (uk format). Now, later on, this data is parsed and, depending upon what does the parsing, the results are different (01-Feb-10 vs. 02-Jan-10 for example). Given that th...

Format DateTime to UTC with FileHelpers

I have a record that I write out to a CSV file using FileHelpers. I want the DateTime fields of the structure to be written out as the UTC date. I currently have the following formatter: [FieldConverter(ConverterKind.Date, "yyyy-MM-dd")] What do I need to do to get it to output the UTC date? ...

Call program with time offset on Linux

I would like to call a program or a script with a relative time offset (or, alternatively, with an absolute time value) on Linux. Think of it as setting the system date and time, except not globally for the system but locally for the script/program and all its child processes. Is that possible? ...

ActiveRecord doesn't set a datetime field

I have a datetime field called time in my MotionRecord model. I try to set it using this command: MotionRecord.create({:time=> "2010-10-15 15:10:24", :chart_id=>1}) Oddly enough this results in the following input: <MotionRecord id: 1, time: nil, chart_id: 1> I'm not sure what I am doing wrong. Edit: This is my model. class Moti...

How do i know timezones - PHP

How can i know the current time at different places example:- Local time in America & london wud differ 1) So if a user from USA visit my website, I should be able to show him his local time 2) If a user from London visit my website, his/her local time should be populated how can i solve the above issue ?? Thanx for the help... ...

Is there anyway I could use nullable datetime property to get the year ?

I am trying to perform the following linq to entities query- var data = DataContext.Employee.Where(e=>e.Date.Year>1986).ToList(); Now the problem is that Date field is a nullable DateTime field and I can't access Year property and on the database side I can't change legacy code! ....anyways is there anyway possible to use the year pr...

Use PHP to truncate the age of a MySQL entry to the nearest unit of time

I have a table with a datetime field, and I want to pull that time stamp and use PHP to convert it to the nearest largest unit of time. For example, if the entry was made 2 minutes and 36 seconds ago, I want to echo 2 minutes in PHP. If it was 3 hours and 5 minutes ago, I want it to say 3 hours. If it was 6 days and 4 hours and 40 minute...

A very simple java code (to get date of a week day), but Very Strange result I get, WHY??

Hi, I have the following java code to get the date of a specific week day: SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); Calendar cal = Calendar.getInstance(); cal.setTime(new Date()); cal.set(Calendar.YEAR, 2010); cal.set(Calendar.WEEK_OF_YEAR, 37); //week 37 of year 2010 cal.set(Calendar.DAY_OF_WEEK, Calendar.THURSDAY); S...

How to compare two datetimes

I wonder how to compare two DateTime objects in .NET using DateTime methods Compare, CompareTo or Equals without comparing ticks. I only need a tolerance level of milliseconds or seconds. How can this be done? ...

Maximum time() | PHP

It's kind of a silly question, but what would be the maximum INT value of a time() and it's future date, e.g. 1st January 2999 Would time() ever get to that value? Going for a large time() value would return this: Thu 1st Jan 1970 1:00AM A normal int date 1287320788 - outputs today's date: Sun 17th Oct 2010 2:06PM But ...

What is the recommended way of doing date arithmetics in Perl?

What is the recommended way of doing date arithmetics in Perl? Say for example that I want to know the date three days ago from today (where today = 2010-10-17 and today - 3 days = 2010-10-13). How would you do that in Perl? ...

in asp.net MVC 2 /beta Date formate proble is as :

Hi, in asp.net mvc 2 or beta , model not accepting the date 13 ( more than 12'th of date) . Model showing error ads " The value '20/10/2010' is not valid for MyDateFieldName " what have to do ? Model showing false status as ModelState=False. why ? ...