?
Solved

Convert Error

Posted on 2008-10-24
7
Medium Priority
?
274 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
7 Comments
 
LVL 14

Expert Comment

by:Binuth
ID: 22794452
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
ID: 22794458
I changed

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

to

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

Author Comment

by:srirama_rao
ID: 22794706
ur correct but i want the date in the format mm/dd/yyyy
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 14

Accepted Solution

by:
Binuth earned 2000 total points
ID: 22794727
use

convert(varchar,project.start_dt,101)

instead of

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

Author Comment

by:srirama_rao
ID: 22794971
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
ID: 22795008
what error you getting ?
0
 
LVL 9

Expert Comment

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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

719 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