doramail05
asked on
Dateformat for sql server in WHERE clause
having
dd-MM-YYYY
MM-dd-YYYY
YYYY-MM-dd
still they won't accept.
dd-MM-YYYY
MM-dd-YYYY
YYYY-MM-dd
still they won't accept.
Select a.id AS idname, a.userid AS useridname, a.a_categoryid AS acategoryidname, a.code AS acodename, a.pointid AS pointidname,
a.title AS titlename, a.briefdesc AS briefdescname, a.contentdesc AS contentdescname, a.filepath AS filepathname, a.pageno AS pagenoname,
a.datecreated AS datecreatedname, a.datemodified AS datemodifiedname, ut.name AS utname
from article a
inner join usertable ut on a.userid = ut.id
WHERE a.a_categoryid = 5 AND a.datecreated = '11-13-2010';
Select a.id AS idname, a.userid AS useridname, a.a_categoryid AS acategoryidname, a.code AS acodename, a.pointid AS pointidname,
a.title AS titlename, a.briefdesc AS briefdescname, a.contentdesc AS contentdescname, a.filepath AS filepathname, a.pageno AS pagenoname,
a.datecreated AS datecreatedname, a.datemodified AS datemodifiedname, ut.name AS utname
from article a
inner join usertable ut on a.userid = ut.id
WHERE a.a_categoryid = 5 AND convert(datetime, a.datecreated, 101) = '11-13-2010';
Select a.id AS idname, a.userid AS useridname, a.a_categoryid AS acategoryidname, a.code AS acodename, a.pointid AS pointidname,
a.title AS titlename, a.briefdesc AS briefdescname, a.contentdesc AS contentdescname, a.filepath AS filepathname, a.pageno AS pagenoname,
a.datecreated AS datecreatedname, a.datemodified AS datemodifiedname, ut.name AS utname
from article a
inner join usertable ut on a.userid = ut.id
WHERE a.a_categoryid = 5 AND convert(datetime, a.datecreated, 110) = '11-13-2010';
another article worth reading
http://www.sqlusa.com/bestpractices/datetimeconversion/
try without '-', eg: a.datecreated = '20101113' (yyyymmdd)
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
aiks, none of them ~ o.o
can you post some results
select datecreated from article where ....
for sample data
select datecreated from article where ....
for sample data
ASKER
this should be alright
Select a.id AS idname, a.userid AS useridname, a.a_categoryid AS acategoryidname, a.code AS acodename, a.pointid AS pointidname,
a.title AS titlename, a.briefdesc AS briefdescname, a.contentdesc AS contentdescname, a.filepath AS filepathname, a.pageno AS pagenoname,
a.datecreated AS datecreatedname, a.datemodified AS datemodifiedname, ut.name AS utname
from article a
inner join usertable ut on a.userid = ut.id
WHERE a.a_categoryid = 5 AND a.datecreated between '2010-11-13' and DATEADD(DAY,1,'2010-11-13');
pls try: convert(datetime,convert(c har(10),da tecreated, 101)) = '20101113'
hope you are aware that example date is in the future
hope you are aware that example date is in the future
http://www.sql-server-helper.com/tips/date-formats.aspx