New Years Day TimeStamp

Some work I’ve been involved with (see here and here) with UNIX Timestamps threw up another challenge today- getting the timestamp for midnight on January 1st of the current year. This is what I came up with:

SQL (using MySQL 5.5)

1mysql> SELECT UNIX_TIMESTAMP(DATE_FORMAT(NOW(),'%Y-01-01 00:00:00'));
2+--------------------------------------------------------+
3| UNIX_TIMESTAMP(DATE_FORMAT(NOW(),'%Y-01-01 00:00:00')) |
4+--------------------------------------------------------+
5| 1325376000 |
6+--------------------------------------------------------+
71 row in set (0.00 sec)

Excel (using Office 2003)

1=(DATE(YEAR(NOW()),1,1)-DATE(1970,1,1))*86400

Visual BASIC (using Visual Studio .NET 2005)

1Console.WriteLine(DateAndTime.DateDiff(DateInterval.Second, CDate("1970-01-01 00:00:00"), CDate(Now.Year.ToString + "-01-01 00:00:00")))