datetime problem
-
hello i am gayatri patil i have two table tAnalyst and tUser tAnalyst:- UserId varchar(20) notnull CreateDate datetime(8) notnull UpdateDate datetime(8) allow Null tUser table:- UserId varchar(20) notnull firstname varchar(20) notnull lastname varchar(20) notnull i want sql query like join the two tables and search data date wise. my query is-------- select tU.UserID,tU.FirstName,tU.LastName, tU.LastName+''+ tU.FirstName'UserId', tA.UserID,tA.CreateDate, tA.UpdateDate from tAnalyst tA, tUser tU where tU.UserID=tA.UserID and tA.CreateDate = '7/25/2007' in this query i haven't error but data is not display. so pls guide me writeway. regards gayatri Gayatri
-
hello i am gayatri patil i have two table tAnalyst and tUser tAnalyst:- UserId varchar(20) notnull CreateDate datetime(8) notnull UpdateDate datetime(8) allow Null tUser table:- UserId varchar(20) notnull firstname varchar(20) notnull lastname varchar(20) notnull i want sql query like join the two tables and search data date wise. my query is-------- select tU.UserID,tU.FirstName,tU.LastName, tU.LastName+''+ tU.FirstName'UserId', tA.UserID,tA.CreateDate, tA.UpdateDate from tAnalyst tA, tUser tU where tU.UserID=tA.UserID and tA.CreateDate = '7/25/2007' in this query i haven't error but data is not display. so pls guide me writeway. regards gayatri Gayatri
-
hello i am gayatri patil i have two table tAnalyst and tUser tAnalyst:- UserId varchar(20) notnull CreateDate datetime(8) notnull UpdateDate datetime(8) allow Null tUser table:- UserId varchar(20) notnull firstname varchar(20) notnull lastname varchar(20) notnull i want sql query like join the two tables and search data date wise. my query is-------- select tU.UserID,tU.FirstName,tU.LastName, tU.LastName+''+ tU.FirstName'UserId', tA.UserID,tA.CreateDate, tA.UpdateDate from tAnalyst tA, tUser tU where tU.UserID=tA.UserID and tA.CreateDate = '7/25/2007' in this query i haven't error but data is not display. so pls guide me writeway. regards gayatri Gayatri
-
hello i am gayatri patil i have two table tAnalyst and tUser tAnalyst:- UserId varchar(20) notnull CreateDate datetime(8) notnull UpdateDate datetime(8) allow Null tUser table:- UserId varchar(20) notnull firstname varchar(20) notnull lastname varchar(20) notnull i want sql query like join the two tables and search data date wise. my query is-------- select tU.UserID,tU.FirstName,tU.LastName, tU.LastName+''+ tU.FirstName'UserId', tA.UserID,tA.CreateDate, tA.UpdateDate from tAnalyst tA, tUser tU where tU.UserID=tA.UserID and tA.CreateDate = '7/25/2007' in this query i haven't error but data is not display. so pls guide me writeway. regards gayatri Gayatri
Data stored in CreatedDate colum is DateTime i.e. the column has both date and Time. but while retrieving you are using only Date. so Automatically system takes time as "00:00:00" change you condition to ... ta.CreateDate BETWEEN '25-Jul-2007' AND '26-Jul-2007'
Regards KP
-
hello i am gayatri patil i have two table tAnalyst and tUser tAnalyst:- UserId varchar(20) notnull CreateDate datetime(8) notnull UpdateDate datetime(8) allow Null tUser table:- UserId varchar(20) notnull firstname varchar(20) notnull lastname varchar(20) notnull i want sql query like join the two tables and search data date wise. my query is-------- select tU.UserID,tU.FirstName,tU.LastName, tU.LastName+''+ tU.FirstName'UserId', tA.UserID,tA.CreateDate, tA.UpdateDate from tAnalyst tA, tUser tU where tU.UserID=tA.UserID and tA.CreateDate = '7/25/2007' in this query i haven't error but data is not display. so pls guide me writeway. regards gayatri Gayatri
This is because of format of date is different in your table column field(i.e. CreateDate and you are comparing this date with another format which is mm/dd/yyyy. If you want to do it then you have to convert your format and you will sure get result. Now use this query to get the result.
select tU.UserID,tU.FirstName,tU.LastName, tU.LastName+''+ tU.FirstName'UserId', tA.UserID,tA.CreateDate, tA.UpdateDate from tAnalyst tA, tUser tU where tU.UserID=tA.UserID and convert(varchar,tA.CreateDate,101)='07/25/2007'
-
1 . Gaytri it may possible that racords are not matche 2. Or Pass the Date as 07/25/2007 not 7/25/2007 Old tA.CreateDate = '7/25/2007' i think it is problem New tA.CreateDate = '07/25/2007'
-
This is because of format of date is different in your table column field(i.e. CreateDate and you are comparing this date with another format which is mm/dd/yyyy. If you want to do it then you have to convert your format and you will sure get result. Now use this query to get the result.
select tU.UserID,tU.FirstName,tU.LastName, tU.LastName+''+ tU.FirstName'UserId', tA.UserID,tA.CreateDate, tA.UpdateDate from tAnalyst tA, tUser tU where tU.UserID=tA.UserID and convert(varchar,tA.CreateDate,101)='07/25/2007'
-
hello i am gayatri patil i have two table tAnalyst and tUser tAnalyst:- UserId varchar(20) notnull CreateDate datetime(8) notnull UpdateDate datetime(8) allow Null tUser table:- UserId varchar(20) notnull firstname varchar(20) notnull lastname varchar(20) notnull i want sql query like join the two tables and search data date wise. my query is-------- select tU.UserID,tU.FirstName,tU.LastName, tU.LastName+''+ tU.FirstName'UserId', tA.UserID,tA.CreateDate, tA.UpdateDate from tAnalyst tA, tUser tU where tU.UserID=tA.UserID and tA.CreateDate = '7/25/2007' in this query i haven't error but data is not display. so pls guide me writeway. regards gayatri Gayatri
hi whenever you are dealing with dates..convert the dates to a common format... you can use convert function for this. regards Joe