Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Convert Error

Posted on 2008-10-24
7
Medium Priority
?
276 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
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
Veeam and MySQL: How to Perform Backup & Recovery

MySQL and the MariaDB variant are among the most used databases in Linux environments, and many critical applications support their data on them. Watch this recorded webinar to find out how Veeam Backup & Replication allows you to get consistent backups of MySQL databases.

 
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

Veeam Disaster Recovery in Microsoft Azure

Veeam PN for Microsoft Azure is a FREE solution designed to simplify and automate the setup of a DR site in Microsoft Azure using lightweight software-defined networking. It reduces the complexity of VPN deployments and is designed for businesses of ALL sizes.

Question has a verified solution.

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

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…

963 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