SQL

SQL Server date time conversions to/from Unix bigint format UPDATED

Categories:

I am in the middle of a SQL data conversion project. Amazingly, our *new* SQL Server database requires dates to be stored in Unix format, which is a bigint field with the number of milliseconds since 01/01/1970. Amazing, I tell you.

Here are some queries that I have found useful in this project. I have updated this article to include an alternative that does not involve functions.

SQL Convert datetime to just a date

Categories:

Here is how to use the SQL convert function to extract just the date portion of a SQL datetime field.


convert(varchar(10), eventdate, 101)


It will result in something like this:


04/20/2010



You can change the syntax slightly if you want a different date format. Here is the full documentation on the convert function: http://msdn.microsoft.com/en-us/library/aa226054%28SQL.80%29.aspx

Subscribe to RSS - SQL