can someone explain to me this line of code:
datediff(now(),post_date) = 0
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Where are you trying to run this?  The following would be checking to see if the dates match each other.  What you posted wouldn't run in SQL unless you've created some custom functions.

datediff(d,getdate(),post_date) = 0
Lee SavidgeCommented:
Is this mySQL code?

If so, datediff subtracts one date from another so this is checking to see if the result is 0 days as I suspect this is part of an if statement or a select where clause.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
You have posted this in the SQL Server areas, but it actually looks like Access.  Now() is an Access function.  It also looks like you are missing an argument.  The syntax should be DATEDIFF(interval, date1, date2) where interval is the unit of time(days, hours, seconds, milliseconds, etc) and date1 is the start date and date2 is the end date.  The function returns the number of time units between the two dates.  The code you posted, if rewritten correctly, is looking for a value in post_date that is exactly the same as the current date time.


Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

karinos57Author Commented:
yeah, this is mysql code. thx
Lee SavidgeCommented:
If the code is part of a where clause, then it will return all records that are zero days apart. DateDiff in mySQL will take 2 parameters. It will subtract, in your case, now() which is the time and date as it is now, from the post_date which is a field in the table and if the result is zero it will return the record.

See here:

karinos57Author Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.