0

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?

2 Answers 2

1

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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

2 Comments

or do it directly in sql using adddate() or addtime()
Thanks, I used DATEADD instead

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.