views:

61

answers:

2

So I have SQL Server datetime field, and in PHP I want to use this as a UNIX TIMESTAMP, because I want to use it with strtotime, in order to add 14 days into it. Eg. If it is stored in the SQL Server database as: 2010-07-27 13:12:22.040 I want to add 14 days into it to become 2010-08-10 13:12:22.040

How would I do that using PHP with SQL Server datetime field? strtotime() command takes only UNIX timestamp.

If can't be done in PHP with SQL Server , how would I do it in SQL Server and then select it with the values I am selecting?

A: 

strtotime() takes a string date format... but anyway, you can also look into mktime()

Crayon Violent
or do it directly in sql using adddate() or addtime()
Crayon Violent
Thanks, I used DATEADD instead
johnshaddad
+1  A: 

how would I do it in SQL Server and then select it with the values I am selecting?

Use DATEADD:

SELECT DATEADD(dd, 14, date_column)

...to add 14 days to the column value.

OMG Ponies
Thanks! This solved it.
johnshaddad