Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Comparing dates

Guest
Feb 18, 2009 Feb 18, 2009
Hi there

I have a program setup to compare two dates and to email the admin user where appropriate.

Here is the code:

select *
from tusers
where DateDiff(NOW(),PASSWORDCREATED) < 1 AND
siteid = 'site1'

Basically I want to email the admin user at the end of the day if any users have registered for access to the site during the day.

When a person registeres the passwordcreated column is filled with a date. - the date (mySQL datetime field).

So I think the above query should work.

Thanks in advance for any feedback.
385
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 18, 2009 Feb 18, 2009
Every datediff function I know about requires a datepart (day, month, year, etc). I don't see any in yours.
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Feb 19, 2009 Feb 19, 2009
Dan Bracuk wrote:
> Every datediff function I know about requires a datepart (day, month, year, etc). I don't see any in yours.

As well as not providing the proper syntax for a dateDiff() function, as
far as I know, dateDiff() is a ColdFusion function an in the place you
are using it in the SQL statement you need a Database Function, and
every database management system have their own set of date functions.
The documentation of yours will tell you all about them.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Feb 19, 2009 Feb 19, 2009
LATEST
Toby007 wrote:
So I think the above query should work.

It should in MySQL, so long as Passwordcreated has a datatype of date or datetime. However, from your description, Passwordcreated will always be a date in the past. Hence, DateDiff(NOW(),PASSWORDCREATED) will be 0 or more.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources