date

How do I provide a suffix for days of the month?

I need a function to return a suffix for days when displaying text like the "th" in "Wednesday June 5th, 2008". It only need work for the numbers 1 through 31 (no error checking required) and English. ...

java date format incompatible with xquery xs:date format, how to fix?

In java, when using SimpleDateFormat with the pattern: yyyy-MM-dd'T'HH:mm:ss.SSSZ the date is outputted as: "2002-02-01T18:18:42.703-0700" In xquery, when using the xs:dateTime function, it gives the error: "Invalid lexical value [err:FORG0001]" with the above date. In order for xquery to parse properly, the date needs to look like...

How do I get the last possible time of a particular day

Hi , I'm trying to achieve the last possible time of a particular day eg for Date of 2008-01-23 00:00:00.000 i would need 2008-01-23 23:59:59.999 perhaps by using the dateadd function on the Date field? ...

SQL Server 2005 Using DateAdd to add a day to a date

How do I in SQL Server 2005 use the DateAdd function to add a day to a date ...

Time math in Delphi

I have a pretty unusual problem (for me). I am writing an application that will allow a user to change their system time forward or back either by explicit date (change my date to 6/3/1955) or by increment using buttons (go forward 1 month). I'm writing this to help some of my users test some software that requires jumps like this in ...

Date class different in Ruby stdlib and Rails stdlib

I want to use the Date::ABBR_MONTHS constant in my rails application. I see the Ruby stdlib documentation at http://www.ruby-doc.org/stdlib/ which does not seem to have this constant. However, this constant is there at http://stdlib.rubyonrails.org/ What is the difference between these two libraries? This constant is working on my uni...

Converting mysql TIME from 24 HR to AM/PM format

Hi, I want to display the TIME field from my mysql table on my website, but rather than showing 21:00:00 etc I want to show 8:00 PM. I need a function/code to do this or even any pointers in the right direction. Will mark the first reply with some code as the correct reply. ...

Custom Date Formating in J2ME

Hi I would like to format a J2ME Date object to only show the date part, not the date and time. What would be the easiest way? Would probably need to include an external library to do this. Any suggestions? Kind regards, IanG ...

How to convert milliseconds into human readable form?

I need to convert an arbitrary amount of milliseconds into Days, Hours, Minutes Second. For example: 10 Days, 5 hours, 13 minutes, 1 second. I'm pretty sure that the trick is fairly simple, but I'm slammed today so I thought I'd reach out to SO's geniuses for a quick fix. Thanks :) EDIT: The language I'm using does not have this bui...

Is there a better way to find midnight tomorrow?

Is there a better way to do this? -(NSDate *)getMidnightTommorow { NSCalendarDate *now = [NSCalendarDate date]; NSCalendarDate *tomorrow = [now dateByAddingYears:0 months:0 days:1 hours:0 minutes:0 seconds:0]; return [NSCalendarDate dateWithYear:[tomorrow yearOfCommonEra] month:[tomorrow mon...

Best way to find date nearest to target in a list of dates?

I have a list of Date objects, and a target Date. I want to find the date in the list that's nearest to the target date, but only dates that are before the target date. Example: 2008-10-1 2008-10-2 2008-10-4 With a target date of 2008-10-3, I want to get 2008-10-2 What is the best way to do it? ...

Calculating days of week given a week number

Given a week number, e.g. date -u +%W, how do you calculate the days in that week starting from Monday? Example rfc-3339 output for week 40: 2008-10-06 2008-10-07 2008-10-08 2008-10-09 2008-10-10 2008-10-11 2008-10-12 ...

MS SQL datetime prior than 1/1/1900

Surely there is a way to store a date value prior than 1-1-1900 in a column other than varchar? Or do I really have to break this out, and perform my own datetime library for date differences, sorting, and such? Yes, I understand how datetime's are actually stored (an integer value from a specific date), but I remember there being anoth...

Getting System Date in MSVC 6.0

I am trying to get system date in a C program on a MSVC++ 6.0 compiler. I am using a system call: system("date /T") (output is e.g. 13-Oct-08 which is date on my system in the format i have set) but this prints the date to the i/o console. How do i make take this date as returned by above system call and store it as a string value...

Oracle 10gr2: enforce dates entered are between 9am and 5pm?

I want to enforce that date-times that are entered fall between 9am and 5pm. How do I enforce this with ORACLE CHECK constraints? ...

getting the last modified date of a html file

Hi guys, how can i figure out the last modified date of a html file im importing into my web app? The html file is on another server and different users can make updates, when i retrieve the page i want to be able see when it was last updated so i can label the updated date on my homepage. I ...

Is there a good date parser for Java?

Does anyone know a good date parser for different languages/locales. The built-in parser of Java (SimpleDateFormat) is very strict. It should complete missing parts with the current date. For example if I do not enter the year (only day and month) then the current year should be used. if the year is 08 then it should not parse 0008...

Date time parsing that accepts 05/05/1999 and 5/5/1999, etc...

Is there a simple way to parse a date that may be in MM/DD/yyyy, or M/D/yyyy, or some combination? i.e. the zero is optional before a single digit day or month. To do it manually, one could use: String[] dateFields = dateString.split("/"); int month = Integer.parseInt(dateFields[0]); int day = Integer.parseInt(dateFields[1]); int year ...

Comparing hibernate-mapped dates?

How can i map a date from a java object to a database with Hibernate? I try different approaches, but i am not happy with them. Why? Let me explain my issue. I have the following class [1] including the main method i invoke and with the following mapping [2]. The issue about this approach you can see, when you look at the console output....

Getting Precise Times in PHP

I have noticed that regardless of a given script's execution time, every date() call will return the same timestamp regardless of where the function is called within the script. It looks like it just returns the time at which the script first started executing. For logging purposes, it would be extremely useful to be able to get increme...