RecordCount for Queries Off - Please help.

Ok I have 8 queries the one below loops through the MYSQL
database to get the days of the week and then gets the results
where they = 1 - 7 and outputs the results using recordcount.
<cfloop index="i" from="1" to="7">
<cfquery name="dailycount#i#" datasource="123">
SELECT ct_id, ct_time, ct_email
FROM contacts
WHERE DayOfWeek(Right(ct_time, 10)) = #i#
GROUP By ct_email
</cfquery>
</cfloop>
Using that query I get the following numbers 24+26+22+38+27 =
137. Now when I do a similar query here.
<cfquery name="DuringBusinessHours" datasource="123">
SELECT ct_id, ct_time, ct_email
FROM contacts
WHERE DayOfWeek(Right(ct_time, 10)) Between 2 AND 6
GROUP By ct_email
</cfquery>
My number is 134 which is off by 3 points. Anyone have any
thoughts on this?

i think your problem is that you store date values as text
instead of
date objects and the 'date' you pass to DAYOFWEEK function is
not in
correct format. mysql expects a date in YYYY-MM-DD or
YYYY/MM/DD format
while you are passing a date string as YYYY/DD/MM. thus some
of the
'dates' you pass to the function will validate as dates but
others will
not - in any case even the ones that do validate will be NOT
the dates
you espect (i.e. if you pass '2008/01/10' expecting it to
return day of
week for October 1, 2008, it will actually return day of week
for
January 10, 2008 because of the wrong date format you are
passing to the
function)
run this simple test:
<cfquery name="q1" datasource="you_dsn_here">
SELECT DAYOFWEEK(RIGHT('11:00 2008/14/09', 10)) AS date1,
DAYOFWEEK(RIGHT('11:00 2008/09/14', 10)) AS date2
FROM some_table_name_here
</cfquery>
<cfoutput>DATE1: #q1.date1# | DATE2:
#q1.date2#</cfoutput>
you will see that the above returns NULL (empty string) for
DATE1
(because the date passed to function - day 9 of month 14 of
year 2008 -
in is not valid), and 1 for DATE2.
lesson learned: a) store your dates as dates to avoid this;
b) read you
db docs to see what a function expects as arguments.
hth
Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/

Similar Messages

  • I use iPhone 4S .earlier with ios 6 and now ios 6.while I connect the charger for charging my phone network lost while midway in charging.that problem always while 3G connection is active.but this problem not arise while 3G mode off.please help me.

    I use iPhone 4S .earlier with ios 6 and now ios 6.while I connect the charger for charging my phone network lost while midway in charging.that problem always while 3G connection is active.but this problem not arise while 3G mode off.please help me.

    reset all settings
    settings-general-reset-reset all settings
    now reconnect to wifi
    settings- wifi- click network name- enter password - join
    if issue persists back up and restore as new via iTunes
    Peace, Clyde

  • TS4085 I reboot my router updated to IOS 5, still NO on/off selection for mirroring..please help getting disappointed

    I reboot my router updated to IOS 5, still NO on/off selection for mirroring..please help getting disappointed

    What are you trying to mirror from? Mirroring from your Mac won't be available until Mountain Lion 10.8  www.apple.com/macosx/mountain-lion/
    Setting up and troubleshooting AirPlay Mirroring
    support.apple.com/kb/TS4085 

  • Hi my ipad air wont charge unless its turnt off please help i just boght a new charger it still wont work

    hi my ipad air wont charge unless its turnt off please help i just boght a new charger it still wont work

    Hi When  you change your iPad, even if its off it will, turn on when you connect, to charger Check  lightining port for any bits. Do a Reboot press &hold power button & menu button hold both down until you see Apple Logo This may help. Cheers Brian

  • HT4623 i disconnected my iphone 4 while it was updating and now its frozen, the screen is showing a apple logo and a loading bar which has been for 9hrs now. please help

    i disconnected my iphone 4 while it was updating and now its frozen, the screen is showing a apple logo and a loading bar which has been for 9hrs now. please help

    It's not uncommon for it to not work the first time and sometimes, you have to try it a few times. Turn off your antivirus software and your firewall while you are trying to restore the iPad. Enable them again after you restore.
    If that still won't work, post back with detailed information as to what exactly does happen as you go through the process.

  • My ipod touch turns off and on all the time i cant charge it because after about 2 minutes it turns off PLEASE HELP!

    MY Ipod touch frequently turns on and off please help!!!

    Try connecting the iPod to its syncing computer and restoring the iPod.
    If you can't restore, see if resetting the iPod will allow a restore:
    Reset iPod touch:  Press and hold the On/Off Sleep/Wake button and the Home
    button at the same time for at least ten seconds, until the Apple logo appears.
    If that was unsuccessfulm see if placing the iPod in recovery mode will allow a restore.  For recovery mode see:
    iPhone and iPod touch: Unable to update or restore

  • Welcome. At the outset, I'm sorry for my English :) Please help with configuration Photoshop CS6 appearance. How to disable the background of the program so you can see the desktop. (same menus and tools) Chiałbym to be the same effect as CS5.

    Welcome.
    At the outset, I'm sorry for my English
    Please help with configuration Photoshop CS6 appearance.
    How to disable the background of the program so you can see the desktop. (same menus and tools)
    i wantto be the same effect as CS5.

    Please try turning off
    Window > Application Frame

  • Whenever I select iTunes It shows that it cannot open iTunes Store . What am I supposed to do for that ? Please help .

    Whenever I select iTunes It shows that it cannot open iTunes Store . What am I supposed to do for that ? Please help .

    Saw this on another post.
    Applecare Senior Advisor Txx Bxxx (I have his contact info in an email he just sent) just confirmed with me that the problem people are having with the App Store not loading is an apple issue with there servers, ITS NOT YOUR IPAD so don't go restoring it!   It's not happening to everyone however but they are looking into it, its really hit or miss.
    In the meantime ...........
    The Complete Guide to Using the iTunes Store
    http://www.ilounge.com/index.php/articles/comments/the-complete-guide-to-using-t he-itunes-store/
    Can't connect to the iTunes Store
    http://support.apple.com/kb/TS1368
    iTunes: Advanced iTunes Store troubleshooting
    http://support.apple.com/kb/TS3297
    Best Fixes for ‘Cannot Connect to iTunes Store’ Errors
    http://ipadinsight.com/ipad-tips-tricks/best-fixes-for-cannot-connect-to-itunes- store-errors/
    Try this first - Reset the iPad by holding down on the sleep and home buttons at the same time for about 10-15 seconds until the Apple Logo appears - ignore the red slider - let go of the buttons.
    This works for some users. Not sure why.
    Go to Settings>General>Date and Time> Set Automatically>Off. Set the date ahead by about a year.Then see if you can connect to the store.
     Cheers, Tom

  • I Was updating my ipod touch and it was all going ok until the white apple with the bar came up and then itunes crashed out, it is still on with the white apple and i cant turn it off please help me

      Was updating my ipod touch and it was all going ok until the white apple with the bar came up and then itunes crashed out, it is still on with the white apple and i cant turn it off please help me this has been like this for 30 minutes

    Did you try to reset by holding the sleep and home button until the Apple logo comes back again?
    If this does not work, try to connect again in recovery mode: http://support.apple.com/kb/HT1808

  • My MacAir is great except for a problem i have. Keys F1, F2,F5,F6,F7,F8,F9,F10,F11,F12 and the power button are unresponsive. These are keys i frequently use and i have searched the whole apple help centre. Anyone got answers for me? Please helP!!!

    My MacAir is great except for a problem i have. Keys F1, F2,F5,F6,F7,F8,F9,F10,F11,F12 and the power button are unresponsive. These are keys i frequently use and i have searched the whole apple help centre. Anyone got answers for me? Please helP!!!

    Some keys don't work as expected
    From the Apple menu, choose System Preferences.
    From the View menu, choose Speech.
    Click the Text to Speech tab.
    If "Speak selected text when the key is pressed" is enabled, the key or key combination set to speak text cannot be used for other purposes or used to type text--click Set Key and change it to a less-commonly used key combination (try to use modifier keys such as Shift, Command, Option, and Control). Or, disable the "Speak selected text when the key is pressed" option.
    Click the Universal Access pane in System Preferences, click the Keyboard tab.
    Make sure that Slow Keys is turned off. With Slow Keys on, you need to press a key for a longer period of time for it to be recognized.
    In the Universal Access pane, click the Mouse tab, and make sure Mouse Keys is turned off. With Mouse Keys enabled, you cannot use the Numeric Keypad to enter numbers--instead the keypad moves the pointer (cursor). (There is an option to enable Mouse Keys with five presses of the Option key; you may want to turn that option off to avoid accidentally enabling it.) If Mouse Keys is enabled and you are using a keyboard with no numeric keypad or Num Lock function, see Unable to type while Mouse Keys is enabled in Mac OS X.
    If the function keys on the top row of the keyboard are not working as expected, see Mac OS X: How to change the behavior of function keys.
    If the issue persists, use Keyboard Viewer to help isolate the issue:
    Click the Language & Text pane (Mac OS X v10.6) or International pane (Mac OS X v10.5.8 or earlier) in System Preferences.
    Click the Input Sources tab (or Input Menu tab in Mac OS X 10.5.8 or earlier).
    Click the Keyboard & Character Viewer "On" checkbox to select it (click the Keyboard Viewer "On" checkbox in Mac OS X 10.5.8 or earlier).
    From the Input (flag) menu, choose Show Keyboard Viewer.
    If the keyboard is connected and detected by Mac OS X, the keys you type will highlight in the Keyboard Viewer window. Open TextEdit (or any text application), and try to type something using the keys that were previously not responding to see if they highlight in Keyboard Viewer.
    Start from the Mac OS X Install Disc, choose Terminal from the Utilities menu and test the keys which were previously not working.  If the keys work while started from the Install disc, then the keyboard itself is working correctly.  Use Mac OS X: How to troubleshoot a software issue to isolate the software issue that may be causing the keys to not respond.
    http://support.apple.com/kb/TS1381

  • I have one of the old macbooks and wish to hook it up to my tv. do i need a mini dvi to hdmi adapter plus a 3 rca phono lead with a jack for the sound. please help as im useless at this stuff. cheers

    i have one of the old macbooks and wish to hook it up to my tv. do i need a mini dvi to hdmi adapter plus a 3 rca phono lead with a jack for the sound. please help as im useless at this stuff. cheers

    First we need to know which one of the 9 different models of MacBook you have. To see which model you have go to the Apple in the upper left corner and select About This Mac, then click on More Info (and then System Report if you’re running 10.7 Lion). When System Profiler comes up check the Model Identifier and post it back here.
    The Late 2008 model 5,1 Aluminum Unibody and the Late 2009 model 6,1 and Mid 2010 model 7,1 White Unibody have a Mini DisplayPort. The Early 2006 model 1,1 through Early 2008 model 4,1s plus the Early and Mid 2009 model 5,2s have Mini-DVI ports. Each would take a different adapter to connect with the TV.

  • Ever since the last update, My iTunes continues to quit unexpectedly. It will open for one second and then close. Anyone have a solution for this. Please help.

    Ever since the last update, My iTunes continues to quit unexpectedly. It will open for one second and then close. Anyone have a solution for this. Please help.
    I've tried my best to troubleshoot. . . opening in safe mode nothing seems to work.
    In the problem report, this is the error that stood out:
    Crashed Thread:  8  Dispatch queue: com.apple.iad.iadidmanager
    Exception Type:  EXC_BAD_ACCESS (SIGSEGV)
    Exception Codes: KERN_INVALID_ADDRESS at 0x0000000000000090

    Hi there navicin79,
    You may find the troubleshooting steps in the articles below helpful. The first thing I would try is reinstalling iTunes as outlined in the first article.
    Troubleshooting iTunes installation on Mac OS X
    http://support.apple.com/kb/ht2311
    OS X Mavericks: If an app freezes or quits unexpectedly
    http://support.apple.com/kb/PH13975
    -Griff W. 

  • I have updated my 4S i phone with ios 8.1.2, while activating i forgot my password, i am able to sign in my apple id in pc but not not able to sign in my i phone and  message- your apple id has been disable for security reasons please help

    I have updated my 4S i phone with ios 8.1.2, while activating my iphone, i forgot my password. I am able to sign in my apple id in pc (manage my account) but not not able to sign in my i phone and  message- your apple id has been disable for security reasons please help.
    my apple id is with extension @ gmail.com but for activation it is mentioned that it is linked with extension of @me.com

    Hi ulhas1frombanihal,
    Welcome to the Support Communities!  Because your account has been disabled, you will need to contact Apple ID account security to straighten this out.
    Contact Apple for help with Apple ID account security - Apple Support
    http://support.apple.com/en-us/HT5699
    I hope this information helps ....
    - Judy

  • How to use the LAN NetStream for peer transmission, please help, write a sample code

    How to use the LAN NetStream for peer transmission, please help, write a sample code

    No reply, I reply, Oh

  • I have a ipod touch 2nd generation 8gb 4.2.1 im new to itunes i made a itunes account but it says i need a payment method is there anyway i can use my paypal if not is there a way to not have to use a payment method for itunes store please help ty

    i have a ipod touch 2nd generation 8gb 4.2.1 im new to itunes i made a itunes account but it says i need a payment method is there anyway i can use my paypal if not is there a way to not have to use a payment method for itunes store please help ty

    Create a NEW account using these instructions. Make sure you follow the instructions. Many do not and if you do not you will not get the None option. You must use an email address that you have not used with Apple before.
    Creating an iTunes Store, App Store, iBookstore, and Mac App Store account without a credit card
    Using those instructions you may also be able to select PayPal if that is allowed in your country.

Maybe you are looking for

  • Receiver JMS Adapter Communication channel Error

    Hi Experts, The Error is given below Cannot connect because class 'com.ibm.mq.jms.MQQueueConnectionFactory' is missing: ensure that JMS Provider library 'aii_af_jmsproviderlib.sda' contains all required resources. when i searched SDN , i found the MQ

  • Add app to "Open with" in MAIL

    Hello all, in my mail app, when I receive some attached file, I can right clic it and select the app I want to open it with. The problem is, Photoshop is not among that apps list and I want to add it. There is the option "other" (otros) and I can cho

  • Landing Page with Buy now Buttons for products?

    Hi, I've been searching all morning and was hoping someone could point me in the right direction please. We have 1000 products on BC and I wanted to create a custom landing style page offering 3 set products that people can click to buy now. ie just

  • Best quality dvd's

    which software shud i use to get dvd's on the computer and then to the ipod in these stages 1. to pc 2. shrink message back

  • Credit Card Encryption & System Copy

    Hi All, We have done a system copy from PRD back to QA (credit card encryption is activated on both servers). The customer would like to be able to read the PRD data including the credit card details but of course the QA system can only de-crypt its