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

cfif not working

Guest
Jan 31, 2009 Jan 31, 2009

Copy link to clipboard

Copied

I'm can't figure out why this isn't working. If I remove the if block it works. Otherwise, it doesn't.
TOPICS
Advanced techniques

Views

707

Translate

Translate

Report

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

correct answers 1 Correct answer

Community Beginner , Feb 01, 2009 Feb 01, 2009
I'm completely new to CF, so I may be stating the obvious or be completely off mark here, but shouldn't NEQ "0" be NEQ 0. You're comparing to a string. I know that CF handles data types different to what I'm used to, but that's one thing that jumps out at me.

Votes

Translate

Translate
LEGEND ,
Jan 31, 2009 Jan 31, 2009

Copy link to clipboard

Copied

1) define "not working", please. post any errors thrown by cf.
2) what is the value of #date# variable and where is it coming from?
3) easy on the " and # - you have way more of both of them than needed!

that's for starters...

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/

Votes

Translate

Translate

Report

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
Explorer ,
Jan 31, 2009 Jan 31, 2009

Copy link to clipboard

Copied

Since you mention it Azadi, is

DateDiff("d", "#date#", "#now()#")

bad or just excessive compared to

DateDiff("d", date, now())

Votes

Translate

Translate

Report

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 ,
Jan 31, 2009 Jan 31, 2009

Copy link to clipboard

Copied

it is usually just excessive - adds unnecessary processing.
it can be plain bad sometimes, too.
in this case, i'd say it depends on what the value of #date# is - a date
object or a text string...


Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/

Votes

Translate

Translate

Report

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 ,
Jan 31, 2009 Jan 31, 2009

Copy link to clipboard

Copied

now() returns the current date and time down to less than a second. Depending on what your date variable is, it will either never be the same as now(), or will only do so very briefly.

Votes

Translate

Translate

Report

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
Guest
Jan 31, 2009 Jan 31, 2009

Copy link to clipboard

Copied

OK. Sorry about that. It isn't throwing any errors. It just isn't updating like it should. Here is the example: http://tinyurl.com/dedtwv

There are #all.RecordCount# tips in total! This is tip #AllDayRandom#... The current time is #now()# The stored date is #date# <br>
The date difference is #Abs(DateDiff("d", "#date#", "#now()#"))#
This is just tracking so I can see what is going on.

What is supposed to happen is this. The application has 2 tables. 1 of the tables is a single row with 2 columns. date and random_number. It's set up so there is no primary key because basically I'm using it as a variable that gets overwritten. Now what happens is when you visit the page, it is supposed to do a check against the current date and the date stored in the table. If the difference is 1 or more, i.e. it's not today, the query updates the table with the current date and sets a new random number. Then runs the query and displays the new tip of the day based on that new random number. Otherwise it runs through the else block. i.e. it is the same day.

Now, if I remove the if block, it works fine. However, inside of the if block it doesn't work, it just goes right to the cfelse part.

Hope that's clear...

Votes

Translate

Translate

Report

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 Beginner ,
Feb 01, 2009 Feb 01, 2009

Copy link to clipboard

Copied

I'm completely new to CF, so I may be stating the obvious or be completely off mark here, but shouldn't NEQ "0" be NEQ 0. You're comparing to a string. I know that CF handles data types different to what I'm used to, but that's one thing that jumps out at me.

Votes

Translate

Translate

Report

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
Guest
Feb 01, 2009 Feb 01, 2009

Copy link to clipboard

Copied

quote:

Originally posted by: DaveH225
I'm completely new to CF, so I may be stating the obvious or be completely off mark here, but shouldn't NEQ "0" be NEQ 0. You're comparing to a string. I know that CF handles data types different to what I'm used to, but that's one thing that jumps out at me.

You my friend are a freaking genius. You know, nobody caught that but you. I thank you. It works beautifully now.

quote:

Originally posted by: Newsgroup User
what is the exact value of your #date# variable? is it a date object or
a date as text string?

Azadi Saryev
Sabai-dee.com
</blockquote>"> http://www.sabai-dee.com/.[/q[/Q

It's a date. I use #CreateODBCDate(now())# to make it and it's a date field in MySQL. Dave solved the problem for me though. It works now.

Votes

Translate

Translate

Report

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 01, 2009 Feb 01, 2009

Copy link to clipboard

Copied

if it is a date then do not enclose it in " (quotes) when passing it to
DateDiff() function

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/

Votes

Translate

Translate

Report

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
Guest
Feb 02, 2009 Feb 02, 2009

Copy link to clipboard

Copied

LATEST
quote:

Originally posted by: Newsgroup User
if it is a date then do not enclose it in " (quotes) when passing it to
DateDiff() function

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/



Ya, I need to refresh myself on what needs in quotes and what does not.

Votes

Translate

Translate

Report

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 01, 2009 Feb 01, 2009

Copy link to clipboard

Copied

what is the exact value of your #date# variable? is it a date object or
a date as text string?

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/

Votes

Translate

Translate

Report

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
Documentation