datetime

C# DateTime comparisons accuracy and rounding.

I have two dates. One supplied by the user and accurate to the second and one from the database and accurate to the tick level. This means when they both represent 13/11/2009 17:22:17 (British dates) userTime == dbTime returns false The tick values are 633937297368344183 and 633937297370000000. To fix this I use the code userTim...

How to get the day of year in ruby?

What is the best way to get the day of year of an specific date in Ruby? For example: 31/dec/2009 -> 365, 01/feb/2008 -> 32, etc ...

Converting string containing localtime into UTC in C

I have a string containing a local date/time and I need to convert it to a time_t value (in UTC) - I've been trying this: char* date = "2009/09/01/00"; struct tm cal = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL}; strptime(date, "%Y/%m/%d/%H", &cal); time_t t = mktime(&cal); but the time_t value I get back is the value that I would expect if ...

Mysql compaire two dates from datetime?

I was try to measure what is faster and what should be the best way to compare two dates, from datetime record in MySql db. There are several approaches how to grab a date from date time, but I was concentrate on two one is to use DATE function and second is to use LEFT function, something like this DATE(created_on) , and for LEFT...

MYSQL DATE function running insanely slow in LEFT JOIN

When adding the line: LEFT JOIN core_records_sales as sales ON DATE(appointments.date) = DATE(sales.date_sold) To my query, it boosts the time for the script to run from about 8 seconds, to 2-3 minutes. Would there be some data causing this problem or am I not implementing the function correctly? I need to use DATE() because I need ...

Unix timestamp to .net DateTime

I must be doing an obvious mistake but I can't figure it out. I am importing a date stored in a mysql database (it is stored by the ExpressionEngine CMS). It is a unix timestamp, i.e. seconds since 1/1/1970 00:00. So I'm doing something like this: DateTime dateTime = new System.DateTime(1970, 1, 1, 0, 0, 0, 0); dateTime = dateTime.Add...

How can I have a function perform after a Datetime in my DB is met?

I'm creating an auction site where users can bid on items. I want to create a script that sends an email to the winner of an auction item once the datetime in the end_auction column has been reached. I'm not sure how to go about doing this, since PHP only runs when the page is loaded and then stops. Also, I want it to send an email to ...

method to display float in datetime format

I need a method in c# that makes me a string that look like a datetime out of a double/float. for example 1.5 -> 01:30 2.8 -> 02:48 25.5 -> 25:30 (note: don't display as day, display full hours even its more than 24) ...

break apart formatted date into individual month/day/year hour/minute/second in php

I have a date in the following format November 18, 2009, 3:00PM How can i break that up so that i can store each value as its own variable? such as... $month //November $day //18 $year //2009 $hour //03 $minute //00 $ampm //PM ---------------Solution---------------- $startdate = "November 18, 2009, 3:00PM"; list($month,$day,$yea...

How to catch onmouseleave event for TDateTimePicker component in Delphi 7

I need to detect OnMouseLeave event for TDateTimePicker component, but it doesn't contain such event in events list. Is there a way to detect it manually? ...

How to calculate difference in hours (decimal) between two dates in SQL Server?

I have to calculate the difference in hours (decimal type) between two dates in SQL Server 2008. I couldn't find any useful technique to convert datetime to decimal with 'CONVERT' on MSDN. Can anybody help me with that? UPDATE: To be clear, I need the fractional part as well (thus decimal type). So from 9:00 to 10:30 it should return m...

C# Define begin of day of a date in another timezone

Hi, I want to define the begin of a day in another timezone with .NET/C#. Example: My current timezone = GMT+1 so DateTime.Today returns 19/11/2009 23:00 UTC but actually I want to get the DateTime.Today for timezone GMT+2 which would be 19/11/2009 22:00 UTC. How do I do this without juggling with offsets & daylightsaving calcu...

Converting a 64-bit long UTC timestamp into Actionscript Date

I'm using a Java 64-bit long representation of UTC time System.currentTimeInMillis() and sending that to an Actionscript client as a String, and I want to convert to an Actionscript UTC Date. The trouble is Actionscript (and other ECMAScript like Javascript) only use a 64-bit Floating point number representation, so precision is lost w...

Linq-to-Entities: Format Date in select query expression

I am trying to get a formatted date string directly from a LINQ-to-Entities query expression. nonBusinessDays = (from ac in db.AdminCalendar where ac.DateTimeValue >= calendarStartDate && ac.DateTimeValue <= calendarEndDate && ac.IsBusinessDay == false select ac.MonthValue + "/" + ac.DayOfMonth + "/...

Get DateTime Obj from "mm/yyyy" format Date string

Hi, I have a date string in format "08/1999" I want to get the first date of the corresponding month. eg : in this case 08/01/1999. It is simple for en-Us culture. I break the string, append "01" in the string to get 08/01/1999 and then DateTime.Parse(datestring) but this is valid for en-US culture only. How can I do this for differ...

C# , How can i build a DateTime object from a datetime present in a string object ?

in C# , How can i build a DateTime object from a datetime present in a string object ( String strDate="11/11/2009")? ...

Override DateTime.ToString to use "o" instead of "G"

Is there any way in .Net I can get the default format used by DateTime.ToString() to change from ToString("G") to ToString("o")? I don't have the option of using a different overload it has to be ToString(). Update: I found a way to do what I need using DateTimeOffset but it was very useful to see Gonzalo's solution. ...

Culture-conversion in C# with DateTime

I'm having trouble getting my ASPX-App to work on the productive server. As my local environment is german but the server is english and my whole code didn't provide culture-support, I'm currently implementing that throughout the script. As you might think, as I'm writing this in here, it doesn't quite work the way I want it to. The Ap...

app engine: string to datetime?

i have string date = "11/28/2009" hour = "23" minutes = "59" seconds = "00" how can i convert to datetime object and store it in datastore? ...

Given a date range, count # of workdays per pay period the range falls in

I have a list of roughly 6500+ rows in Excel2007. Each row represents the time that a person was on disability leave with a start date and an end date. If there is no end date, then the end date is set to 12/31/9999. A sample of some values is below: Workers Compensation 4/7/2009 12/31/9999 Workers Compensation 5/21/2009 12/31/...