| Author |
Topic |
|
Pinto
Aged Yak Warrior
590 Posts |
Posted - 2010-02-12 : 09:10:00
|
| Why doesn't this work ? No records are returned. the connection string works because if I remove the filter all records are returned. The code is in a vs console applicationmyCommand = New SqlCommand("Select * from tblSS_Cases WHERE SS_RemindMe = " + Today(), myConnection)There are records there with this in SS_RemindMe field12/02/2010 00:00:00 |
|
|
jimf
Master Smack Fu Yak Hacker
2875 Posts |
Posted - 2010-02-12 : 09:14:42
|
| Today() is not an MS SQL server command. Also, that would give you minutes, so you need to strip those off.This removes the time piece in sql serverSELECT dateadd(day,datediff(day,0,getdate()),0)JimEveryday I learn something that somebody else already knew |
 |
|
|
webfred
Master Smack Fu Yak Hacker
8781 Posts |
Posted - 2010-02-12 : 09:17:19
|
What is the output of Today() and what data type is SS_RemindMe?Sample values? No, you're never too old to Yak'n'Roll if you're too young to die. |
 |
|
|
Pinto
Aged Yak Warrior
590 Posts |
Posted - 2010-02-12 : 09:18:23
|
| Thank you but I am running this in VB and when I enter your code day and getdate are underlined in blue |
 |
|
|
Pinto
Aged Yak Warrior
590 Posts |
Posted - 2010-02-12 : 09:20:22
|
| CA_Remindme is datetime. Today is, well - today. I am in the Uk so dates are dd/mm/yyyy |
 |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2010-02-12 : 09:21:05
|
Include it within the command..like..myCommand = New SqlCommand("Select * from tblSS_Cases WHERE SS_RemindMe = dateadd(day,datediff(day,0,getdate()),0)" , myConnection) |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2010-02-12 : 09:23:48
|
quote: Originally posted by Pinto CA_Remindme is datetime. Today is, well - today. I am in the Uk so dates are dd/mm/yyyy
wherever you're dates are stored in sql table as integer values internally and always displayed in ccyy-mm-dd hh:mi:ss format. you dont have to be worried about format in which you store dates as you can always retrieve it in format you want using formatting functions at front end------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
Pinto
Aged Yak Warrior
590 Posts |
Posted - 2010-02-12 : 09:24:56
|
| Thank you vijayisonly - I was trying to assign it to a variable in my code. It now works |
 |
|
|
vijayisonly
Master Smack Fu Yak Hacker
1836 Posts |
Posted - 2010-02-12 : 09:58:28
|
| You're welcome. |
 |
|
|
|