datetime

MySQL: Calculate the difference between Date/Times - only during M-F "Work week"

I need to calculate a difference between a starting date/time and an ending date/time. But, I only want to do this for the 5-day work week (exclude Sat/Sun as days). What is the best way to do this? My thought is that from the date, I'll have to get the day of the week and if it is a weekday, then I add to the accumulator. If it's no...

SQLite: date stored as integer, comparision fails.

Hi, I have kind of strange problem ... I have a table which stores a timestamp as integer (realdate field). Now there are the results of selecting items younger than some date: SELECT realdate FROM photos WHERE realdate > 1265410800 array 0 => array 'realdate' => string '1265629201' (length=10) 0 => string '12656...

Filtering DataGridView By Date Prior to Printing

I am filtering the DataGridView by a TIMESTAMP column so users can determine the date of data to print. Following is how I am creating my filtered DataGridView. However, in order to get the correct dates for instance Feb 8, 2010 to Feb 10, 2010, I have to select one date prior so the date range has to be Feb 7, 2010 to Feb 10, 2010 to ge...

Business days in Python

Hello, I need to subtract business days from the current date. I currently have some code which needs always to be running on the most recent business day. So that may be today if we're Monday thru Friday, but if it's Saturday or Sunday then I need to set it back to the Friday before the weekend. I currently have some pretty clunky cod...

Specify a date in another timezone C#

I've got an asp.net application that must run some code every day at a specific time in the Eastern Time Zone (DST aware). So my first thought is, get the eastern time value and convert it to local server time. So I need something like this: var eastern = DateTime.Today.AddHours(17); // run at 5pm eastern var timeZoneInfo = TimeZoneIn...

How to get DataSet.ReadXml to parse a DateTime attribute as a typed DateTime

I have an XML string which contains Dates formatted "dd/MM/yyyy hh:mm:ss". I'm loading this XML into a dataset using DataSet.ReadXml(). How can I ensure that this Date is stored in the DataSet as a typed DateTime so that I can Sort, Format and RowFilter on it accordingly. My test harness is as below: ASPX Page: <%@ Page Language="C#...

formatting dates with or without a leading zero in php

How would you convert a datestring that will be formated like... m/d/yyyy H:i:s or mm/dd/yyyy H:i:s... and format it like... yyyy-mm-dd H:i:s I can format either of the two inputs into my desired format, but not both. ...

can 2 timezone be for 1 city?

I want to know if there can be 2 or more GMT timezones for one city or state. I know there can be more then one GMT timezone for a country, but not sure if it's for state and city too. Share your knowledge please. ...

c# find same range of "named days" from 1 year ago

using c# visual studio 2008. Can anyone help with an algorithm to do this please if i have a range of days selected for this week (eg monday to friday) i can find the dates for these using the datetime functions available. What i want to do is compared to stored data for the same DAY range 1 year ago. So basicly i need to go back 1 y...

Parse DateTime in c# from strange format

Hi, if i have a datetime string in a weird format, such as YYYY##MM##DD HH**M**SS, how can i create a new datetime object base on that? i have read something about the datetimeformatinfoclass but not sure how to get it working.. ...

How to extract the most common YEAR from an array of DateTime objects using LINQ

Hi, im trying to extract the most common YEAR from an array of DateTime objects using LINQ. can someone help me? With the following its telling me i need to implement IComparable.. DateTime modeDate = (from c in dates group c by c.Year into g select g).Max(...

My PeriodFormatter is not behaving as I expect - what have I done wrong?

I'm having trouble using Joda Time's PeriodFormatter. I want one to report days, hours, minutes and seconds but my attempt seems to be wrapping around weeks. What should I be doing differently? import org.joda.time.DateTime; import org.joda.time.Period; import org.joda.time.format.PeriodFormatter; import org.joda.time.format.PeriodFor...

Matching GPS tracks to local days

I'm writing a geotagging app and running into headaches with timezones. Basically, my app has the following data: Images with local timestamps (i.e. relative to a timezone) GPS track files consisting of entries using UTC timestamps My problem: I need a way to get all data that belongs to a give day, based on the timezone where the da...

MySQL query to evaluate aggregate duration of time something is "on"

I have a series of timestamped on/off data in a table, representing on/off states, or the point at which a state "starts" 00:00:00 0 04:00:00 1 08:00:00 0 09:00:00 1 15:00:00 0 20:00:00 1 23:59:59 0 I need to calculate the total duration of (say) the ON state over a 24h period. In this simplified example total du...

Subtract two dates to give a timedelta

I'm trying to get a value from one of my database values, which will be given by subtracting the purchase date from today's date. I've written my code this way: delta = datetime.now() - item.purchase_date But this gives me this error: unsupported operand type(s) for -: 'datetime.datetime' and 'datetime.date' If I use datetime.date...

How to change string date to MySQL date format at time of import of CSV using MySQL's LOAD DATA LOCAL INFILE

I'm using MySQL's LOAD DATA LOCAL INFILE SQL statement to load data from an CSV file into an existing database table. Here is an example SQL statement: LOAD DATA LOCAL INFILE 'file.csv' INTO TABLE my_table FIELDS TERMINATED BY ',' ENCLOSED BY '"' LINES TERMINATED BY '\n' (name, address, dateOfBirth) The third column in the CSV that m...

ASP.NET MVC 2 Beta: DateTime conversion. Bug or not?

<%= Html.ActionLink(Html.Encode("user3"), "Filter", new { controller = "Search", userName = "user3", dateFrom = DateTime.Now.AddDays(-2).ToString(), dateTo = DateTime.Now.ToString() })%> It's evaluated to this link: http://localhost:60357/Search/Filter?userName=user3&amp;dateFrom=08.02.2010%2023%3A21%3A33&amp;dateTo=10.02...

add days and hours in date/time field and get the updated date/time in php using mysql

I would like to provide the ability for users to submit a datetime value, along with values representing additional days/hours, and then store the datetime that results from adding the two in a mysql database. ...

Changing between images based on date

So I have a website which has three spaces for pictures: Space A, Space B, and Space C. In Space A, I have 20 images (Images A1-A20) which I would like to rotate daily. In Space B, I have 20 images (Images B1-B20) which I would like to change every 13 days. In Space C, I have 20 images (Images C1-C20) which I would like to change every...

Need Help with JQuery UTC Date function

I am trying to use the Jquery Countdown plugin but I am having trouble with my UTC Date formatting. The date I wish to countdown to is Friday 23rd July 2010. Here is the relevant code... until: $.countdown.UTCDate(2010, 7 - 1, 23), format: 'YOD', The output is just 00.00.00 etc Can anybody help me? Thanks in adva...