datetime

Get Previous Day

Possible Duplicate: How to determine the date one day prior to a given date in Java? If I have a Java.Util.Date object, what is the best way to get an object representing the 24 hours in the past of it? ...

How to send on a specific day in php?

Hi, I want to a e-cards or something like that. The user can choose the e-cards, after chosen, he must enter the some fields like name(to and from), email(to and from), message and I want to let user to choose which date to send the e-cards. How to send the e-cards on specific day? I need to write a script that run every new day? How to...

TimeSpan using a nullable date

How can i subtract 2 dates when one of them is nullable? public static int NumberOfWeeksOnPlan(User user) { DateTime? planStartDate = user.PlanStartDate; // user.PlanStartDate is: DateTime? TimeSpan weeksOnPlanSpan; if (planStartDate.HasValue) weeksOnPlanSpan = DateTime.Now.Subtract(planStartDate); // This line is ...

Why does DateTime.Now.ToString("u") not work?

I currently in British summer time which is UTC +1 Hour. I confirmed my PC is correct with the following code and it returns true. System.TimeZone.CurrentTimeZone.IsDaylightSavingTime(Date.Now) My question is then why does the UTC formatter not work as I would expect: DateTime.Now.ToString("u") It returns the exact current system d...

Grouping Date Range by Week

I have a date range where a start date is 2 years prior to today. e.g.) '05/29/2007' ~ '05/29/2009'. How can I break above date range so that I would get a list like the following? (start date starts with "05/27/2007", not "05/29/2007" since the start of weekday is Sunday and '05/27/2007' is the first day of week for '05/29/2007' and t...

What can bite me if I store a datetime as a float in the database?

What can bite me if I store a datetime as a float in the database? I have a very good reason for doing it so don't complain about that :) Edit: I was thinking about just storing convert(float, @thedate) in a float column. ...

Converting String to DateTime C#.net

How do you convert a string suchas 2009-05-08 14:40:52,531 into a datetime? ...

TRY CATCH on a CONVERT in a Select Statement

Is it possible to use TRY CATCH blocks in SQL Selects? For stuff similar to this for example: select order, CONVERT(DATETIME, orderDate) from orders What's the best way of handling this scenario? ...

How to truncate a datetime in SQL Server

What's the best way to truncate a datetime value (as to remove hours minutes and seconds) in SQL Server 2008? For example: declare @SomeDate datetime = '2009-05-28 16:30:22' select trunc_date(@SomeDate) ----------------------- 2009-05-28 00:00:00.000 Thanks ...

Binary Serialization of an Array of DateTime

Hi, when i serialize an array of Int32 using the BinaryFormatter, i get about 400MB/s (100 million items in one second), but when i try to serialize an array of DateTime, i get only a throughput of about 27MB/s (100 million items in 30 seconds). One DateTime occupies eight bytes in serialized form. I guess that the BinaryFormatter uses ...

Get Start and End Days for a Given Week in PHP

I'm trying to get the week range using Sunday as the start date, and a reference date, say $date, but I just can't seem to figure it out. For example, if I had $date as 2009-05-01, I would get 2009-04-26 and 2009-05-02. 2009-05-10 would yield 2009-05-10 and 2009-05-16. My current code looks like this (I can't remember where I lifted it ...

What's a good temporal distance to no longer display relative dates?

Relative dates are great to display the temporal incidence of recent activity, but at what distance is it an inconvenience for the user to see a relative date rather than an absolute one? Let's assume the context is a forum. ...

Get the First or Last Friday in a Month

I'm trying to write a calendar function like this function get_date($month, $year, $week, $day, $direction) { .... } $week is a an integer (1, 2, 3...), $day is a day (Sun, Mon, ...) or number, whichever is easier. The direction is a little confusing, because it does a different calculation. For an example, let's call get_date(...

Using SqlServer uniqueidentifier/updated date columns with Linq to Sql - Best Approach

Rightly or wrongly, I am using unique identifier as a Primary Key for tables in my sqlserver database. I have generated a model using linq to sql (c#), however where in the case of an identity column linq to sql generates a unique key on inserting a new record for guid /uniqueidentifier the default value of 00000000-0000-0000-0000-000000...

Convert a date and time into a MS SQL select query using SelectParameters

Hi all, I have this situation where I have a SqlDatasource control and the select query is like: SELECT col1, col2 FROM table1 WHERE colDate = @date The source of @date is a label with the text: 2009-05-29 12:06:00 I get the following error when I run the query: Conversion failed when converting date and/or time from character ...

Is it possible to create a list of months between two dates in Rails

I am trying to create a page to display a list of links for each month, grouped into years. The months need to be between two dates, Today, and The date of the first entry. I am at a brick wall, I have no idea how to create this. Any help would be massively appriciated Regards Adam ...

how to get formatted date time like 2009-05-29 21:55:57 using javascript?

when using new Date,I get something like follows: Fri May 29 2009 22:39:02 GMT+0800 (China Standard Time) but what I want is xxxx-xx-xx xx:xx:xx formatted time string ...

date diff in asp.net

Hi Can anyone tell me how to calculate the diff between two dates without using .net datetime and timestamp classes? Thanks ...

[MySQL] Adjusting for timezones and DST

On my website, users can set preferences for their current timezone. I have a bunch of datetimes in my database, but I want to show each time appropriately, given A) what timezone they are in, and B) whether or not Daylight Savings is in effect. What is the best way to go about this? ...

Is there an API to convert from "YYYYMMDDHHMMSS.UUUUUU-TZO" format to C# DateTime?

Example: "20080807144334.410187-180" (-180 means GMT minus three hours. Rio de Janeiro in this case.) That string format is returned when I query file creation/change/access times via WMI (that is not totally working; see here). I guess I could parse it the idiot way, extracting year, month etc. from the string positions. But I'd like n...