Solved

Convert Error

Posted on 2008-10-24
7
266 Views
Last Modified: 2012-05-05
     SELECT     Employee.FirstName , Employee.Dept ,
Emp_Time_Track.No_Of_Hrs_Spent , Emp_Time_Track.Status, Project.Project_Id, Project.Project_Nm ,
                     project.convert(varchar(8),start_dt,112), project.convert(varchar(8),start_dt,112) as end_dt, Project.Client_Nm , Task.Task_Nm ,
Task.No_Of_Res_Planned , Task.No_Of_Hrs_Planned , Task.Descr
FROM         Emp_Time_Track INNER JOIN
                      Employee ON Emp_Time_Track.Emp_Id = Employee.Emp_Id INNER JOIN
                      Project ON Emp_Time_Track.Project_Id = Project.Project_Id INNER JOIN
                      Task ON Emp_Time_Track.Task_Id = Task.Task_Id AND Project.Project_Id = Task.Project_Id
WHERE     (Employee.FirstName = 'sam') AND (Employee.Dept = 'sqldba') AND (Project.Project_Nm = 'adg') AND (Task.Task_Nm = 'coding') AND
                      (Project.Start_Dt >= @start_dt) AND (Project.End_Dt <= Project.End_Dt)


The above convert is throwing error.How do i correct the error.Pls assist
0
Comment
Question by:srirama_rao
  • 4
  • 2
7 Comments
 
LVL 14

Expert Comment

by:Binuth
Comment Utility
try this
    SELECT     Employee.FirstName , Employee.Dept ,

Emp_Time_Track.No_Of_Hrs_Spent , Emp_Time_Track.Status, Project.Project_Id, Project.Project_Nm ,

                    convert(varchar(8), project.start_dt,112),convert(varchar(8), project.start_dt,112) as end_dt, Project.Client_Nm , Task.Task_Nm ,

Task.No_Of_Res_Planned , Task.No_Of_Hrs_Planned , Task.Descr

FROM         Emp_Time_Track INNER JOIN

                      Employee ON Emp_Time_Track.Emp_Id = Employee.Emp_Id INNER JOIN

                      Project ON Emp_Time_Track.Project_Id = Project.Project_Id INNER JOIN

                      Task ON Emp_Time_Track.Task_Id = Task.Task_Id AND Project.Project_Id = Task.Project_Id

WHERE     (Employee.FirstName = 'sam') AND (Employee.Dept = 'sqldba') AND (Project.Project_Nm = 'adg') AND (Task.Task_Nm = 'coding') AND

                      (Project.Start_Dt >= @start_dt) AND (Project.End_Dt <= Project.End_Dt)

Open in new window

0
 
LVL 14

Expert Comment

by:Binuth
Comment Utility
I changed

project.convert(varchar(8),start_dt,112)

to

convert(varchar(8),project.start_dt,112)
0
 

Author Comment

by:srirama_rao
Comment Utility
ur correct but i want the date in the format mm/dd/yyyy
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 14

Accepted Solution

by:
Binuth earned 500 total points
Comment Utility
use

convert(varchar,project.start_dt,101)

instead of

convert(varchar(8),project.start_dt,112)
0
 

Author Comment

by:srirama_rao
Comment Utility
If i put anything other than 101 my query is throwing error.If i put 112 my date format (output) is like 20081010,
so i wamted to but a  / or a - as a seperator.  That is why i am looking for a style
0
 
LVL 14

Expert Comment

by:Binuth
Comment Utility
what error you getting ?
0
 
LVL 9

Expert Comment

by:jamesgu
Comment Utility
did you changed project.convert To convert as Binuth said?
                           ^^^^^^^
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now