dates

DateTime Utility for ASP.net

I was wondering if anyone could suggest a utility library that has useful functions for handling dates in ASP.NET easily taking away some of the leg work you normally have to do when handling dates? Subsonic Sugar has some really nice functions: http://subsonichelp.com/html/1413bafa-b5aa-99aa-0478-10875abe82ec.htm http://subsonicprojec...

DateTime.Now vs. DateTime.UtcNow

I've been wondering what exactly are the principles of how the two properties work. I know the second one is universal and basically doesn't deal with time zones, but can someone explain in detail how they work and which one should be used in what scenario? ...

VB.NET on Vista, trying to get date (Today) causes security exception

I have a VB6 program that someone recently helped me convert to VB.NET In the program, when saving files, I stamp them with the date which I was getting by calling the Today() function. When I try to run the new VB.NET code in Vista it throws a permission exception for the Today() . If I run Visual Studio Express (this is the 2008 Exp...

Is there an easy way in .NET to get "st", "nd", "rd" and "th" endings for numbers?

Hi, I am wondering if there is a method or format string I'm missing in .NET to convert the following: 1 to 1st 2 to 2nd 3 to 3rd 4 to 4th 11 to 11th 101 to 101st 111 to 111th This link has a bad example of the basic principle involved in writing your own function, but I am more curious if there is an inbuilt capacity...

Given a Date Object how do I determine the last day of its month?

I'm trying to use the following code but it's returning the wrong day of month. Calendar cal = Calendar.getInstance(); cal.setTime(sampleDay.getTime()); cal.set(Calendar.MONTH, sampleDay.get(Calendar.MONTH)+1); cal.set(Calendar.DAY_OF_MONTH, 0); return cal.getTime(); ...

Using Javascript, how do I make sure a date range is valid?

As the title states, using Javascript, how can I valid two given dates to ensure that they are a valid range? For example, if you have the date 1 January 2010 and the date 6 January 2010, what is the best way to check to see if 6 January 2010 is within seven days of 1 January 2010. ...

How do you convert 00:00:00 to hours, minutes, seconds in PHP?

I have video durations stored in HH:MM:SS format. I'd like to display it as HH hours, MM minutes, SS seconds. It shouldn't display hours if it's less than 1. What would be the best approach? ...

Given two dates what is the best way of finding the number of weekdays in PHP?

The title is pretty much self explanatory. Given two dates what is the best way of finding the number of week days using PHP? Week days being Monday to Friday. For instance, how would I find out that there are 10 week days in between 31/08/2008 and 13/09/2008? ...

Time Parsing in Flex

Is there any way to parse a string in the format HH:MM into a Date (or other) object using the standard libraries? I know that I can parse something like "9/17/2008 10:30" into a Date object using var date:Date = new Date(Date.parse("9/17/2008 10:30"); But I want to parse just 10:30 by itself. The following code will not work. var ...

What languages do date, time, and calendar operations really well?

This is probably too much to ask, but is there any language that does a really terrific job of representing time and date operations? I'll grant straight away that it's really hard to write a truly great time library. That said, are there any widespread languages that have one? Basically, I want something that handles time and date as...

Unix gettimeofday() - compatible algorithm for determining week within month?

If I've got a time_t value from gettimeofday() or compatible in a Unix environment (e.g., Linux, BSD), is there a compact algorithm available that would be able to tell me the corresponding week number within the month? Ideally the return value would work in similar to the way %W behaves in strftime() , except giving the week within the...

Why does Javascript getYear() return 108?

Why does this javascript return 108 instead of 2008? it gets the day and month correct but not the year? myDate = new Date(); year = myDate.getYear(); year = 108? ...

How do I work with quarters (quarterly dates) in ASP.Net using VB.Net 2.0?

I know that Sql Server has some handy built-in quarterly stuff, but what about the .Net native DateTime object? What is the best way to add, subtract, and traverse quarters? Is it a bad thing™ to use the VB-specific DateAdd() function? e.g.: Dim nextQuarter As DateTime = DateAdd(DateInterval.Quarter, 1, DateTime.Now) Edit: Expanding...

SQL Query Help: Transforming Dates In A Non-Trivial Way

I have a table with a "Date" column, and I would like to do a query that does the following: If the date is a Monday, Tuesday, Wednesday, or Thursday, the displayed date should be shifted up by 1 day, as in DATEADD(day, 1, [Date]) On the other hand, if it is a Friday, the displayed date should be incremented by 3 days (i.e. so it becom...

How to return the date part only from a SQL Server datetime datatype

SELECT GETDATE() Returns: 2008-09-22 15:24:13.790 I want that date part without the time part: 2008-09-22 00:00:00.000 ...

Serializing Date in Java

I'm passing around some objects through web service and some of them contain java.sql.Date. Because Date doesn't have empty constructor it doesn't want to get serialized. First part of a question is easy: what is the best way to pass a date between client and service? Second part is bit trickier: Once I decide how to pass dates aroun...

Datetime localization

Hi, My database is located in e.g. california. My user table has all the user's timezone e.g. -0700 UTC How can I adjust the time from my database server whenever I display a date to the user who lives in e.g. new york? UTC/GMT -4 hours ...

Simplest way to create a date that is the first day of the month, given another date

In SQL Server what is the simplest/cleanest way to make a datetime representing the first of the month based on another datetime? eg I have a variable or column with 3-Mar-2005 14:23 and I want to get 1-Mar-2005 00:00 (as a datetime, not as varchar) ...

Formatting Timestamps in Java

Is there a way to format a UTC time into any arbitrary string format I want in java? Basically I was thinking of having some class take the timestamp and I pass it is string telling it how I want it formated, and it returns the formatted string for me. Is there a way to do this? ...

Given a date range (start and end dates), how can I count the days, excluding specified days of the week in .Net?

I'm creating a UI that allows the user the select a date range, and tick or un-tick the days of the week that apply within the date range. The date range controls are DateTimePickers, and the Days of the Week are CheckBoxes Here's a mock-up of the UI: From Date: (dtpDateFrom) To Date: (dtpDateTo) [y] Monday, [n] Tuesday, [y] We...