date

What's the canonical way to create a date from three numbers representing days, months and years?

I have a year 2009, a month 11 and a day 12. All of these are being passed to me as integers. What I want to do is create a date from these. I want to use these as part of my where statement. What is the best way to do it from either a clean code and most importantly a speed point of view? I personally am using MS SQL, which I'm sure w...

Best way to handle storing/displaying dates in different timezones in PHP?

I've been reading up on this topic for the past few hours, and I think I've got a handle on it, but I'd like some confirmation. Situation I want a user in, say, California to be able to post a comment that will be stored in MySQL. I then want a user in, say, Texas to be able to view the comment with the post date adjusted to his or her...

Selecting a date on a mobile web site

I'm working on a web site that includes creating appointments on the mobile site. I have to make it work on IE Mobile. The biggest challenge is to come up with a way to do date selection on a mobile site that: Is compact enough to not take forever to load on the limited-bandwidth cell network. Will work on Windows Mobile 6 Prevents t...

Generate datetime (exp: 09.02.2009) to string date (exp:Monday)

hello my master! i try to learn or generate any codes to learn string day("26.02.2009") ---> give me "wednesday" i need static datefunction in C# . Forexample: datetime Str_day= Returnstringdate("09.02.2009"); ---->Str_day="Monday"; Returnstringdate("09.02.2009") { it must return Monday!!! } OR Returnstringdate("09.02.2009...

How to convert java.util.date to java.sql.date?

I am trying to use java.util.Date as input and then creating a query with it - so I need java.sql.Date. I was surprised to find that it couldn't do the conversion implicitly or explicitly - but I don't even know how I would do this, as the Java API is still fairly new to me. Any suggestions? It seems like this should be an easy feat...

Dealing with dates

So basically I am storing a bunch of calendar events in a mysql table. And I store the day of the week they are supposed to happen, as well as the time. Right now the time is stored as the number of seconds from midnight calculated in GMT. But when I have people log on and check the calendar and they are from a different timezone othe...

Unix epoch time to Java Date Object

I have a string containing the UNIX Epoch time, and I need to convert it to a Java Date Object. String date = "1081157732"; DateFormat df = new SimpleDateFormat(""); // This line try { Date expiry = df.parse(date); } catch ( ParseException ex ) { ex.getStackTrace(); } The marked line is where I'm having trouble. I can't work o...

Validating Date Parameter in SQL Server Stored Procedure

I've written a stored procedure that takes in a date parameter. My concern is that there will be confusion between American and British date formats. What is the best way to ensure that there is no ambiguity between dates such as 02/12/2008. One possibility would be for users to enter a date in a format such as 20081202 (yyyymmdd). Is th...

Google Bookmark Export date format?

I been working on parsing out bookmarks from an export file generated by google bookmarks. This file contains the following date attributes: ADD_DATE="1231721701079000" ADD_DATE="1227217588219000" These are not standard unix style timestamps. Can someone point me in the right direction here? I'll be parsing them using c# if you are fe...

How do I get the number of days between two dates in jQuery?

How do I get the number of days between two dates in jQuery? For example, given two dates in input boxes: <input id="first" value="1/1/2000"/> <input id="second" value="1/1/2001"/> <script> alert(datediff("day", first, second)); // what goes here? </script> ...

Which is more usable, outputting dates relative to now or relative to the main action's point in time?

I was just reading the "Open Letter to Joel and Jeff" and I noticed the dates on the comments are relative to when the blog entry was posted. So that means the first entry will always stay as "12 minutes later" and the next will always be "14 minutes later". From a usability standpoint, does it make more sense to list out times relative...

Python date time, get date 6 months from now

Hey, I am using the datetime module. I am looking to calculate the date 6 months from the current date. Could someone give me a little help doing this? Edit: The reason I am wanting to generate a date 6 months from the current date is to produce a Review Date. If the user enters data into the system it will have a review date of 6 mo...

work out the date of the fourth saturday in the current month

Bit stuck about how to go about this one. Given the current month, I need to to return the date of the fourth saturday of each month. e.g. This month would be Feb 20th, next would be March 27th. Thanks ...

What's the result of the SQL statement "SELECT DATEADD(s,1234567890, '19700101')"?

For some reason, my SQL installation isn't working :) SELECT DATEADD(s,1234567890, '19700101') Maybe this site would help (link from Moose). ...

PHP - Defaulting form field value to the current date

I'm trying to default a value in a field to the current date, but my code: <?php echo '<input type="text" name="makeupassignment" size="50" value="'.date("m/d/y").'">'; ?> is only printing this: '; ?> ...

Date elements in XML

I guess there are two major approaches to date representations in XML: <date>1984-10-27</date> and <date> <year>1984</year> <month>10</month> <day>27</day> </date> Personally I would go for the former. It's more compact and at the same time more readable. The split-up of the second form seems overkill to me; e.g. most of the...

Quickest way to prevent SQL returning data older than Given

Hey there I have a pretty complex database with loads of different tables for different things, every thing of which has a timestamp (Y-M-D h:m:s format) Is there a way I can limit my SQL query to just results from a certain timespan, for example a week ago? If needbe I have a function to convert these timestamps into unix as sqlToUn...

A fresh SQL sequence per day

What would be a good way to create a fresh sequence of serial numbers on a per-day basis in a SQL database? Something like the auto-increment feature of integer columns in some database systems. I'm creating/recording transactions, and the transaction is identified by the pair 'date,serial no'. ...

SAS invalid 'leap year' date issue yymmdd8.

I am reading in some raw data that has a couple of bad dates. Specifically, someone has keyed in "29th Feb" on a NON leap year. For example: data _null_; input test :yymmdd8.; format test date9.; cards; 20270229 run; The customer would like this to revert to the 28th Feb. Is there a quick / efficient method of doing this? eg an eq...

Calculate elapsed time in Java / Groovy

I have... Date start = new Date() ... ... ... Date stop = new Date() I'd like to get the years, months, days, hours, minutes and seconds ellapsed between these two dates. -- I'll refine the question. I just want to get the elapsed time, as an absolute measure, that is without taking into account leap years, the days of each mont...