Click here to Skip to main content
15,897,032 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i tried the following code it shows some error
error number 1046
what is the right syntax to use near (e.hire_date,'%M %d %Y)

What I have tried:

select e.first_name,e.last_name,format date(e.hire_date,'%M %d %Y') as 'Hire date' from employees e;

what is the correct function to use instead format date to list the employees whose hire date is in the format month dd yyyy
Posted
Updated 29-Dec-19 23:57pm

1 solution

Take off the DATE bit and change "Y" to "y":
SQL
SELECT First_name, Last_name,FORMAT(Hire_date,'%M %d %y') AS 'Hire date' FROM Employees;
 
Share this answer
 
Comments
Oviya Sivakumar 30-Dec-19 6:01am    
i had tried
select e.first_name,e.last_name,format(e.hire_date,'%M %d %y') as 'Hire date' from employees e;

it shows
Truncated incorrect INTEGER value: '%M %d %y'
OriginalGriff 30-Dec-19 6:13am    
Same error, different code, different field:
https://www.codeproject.com/Answers/5255259/How-to-solve-truncated-incorrect-integer-value-in?cmt=1033889#cmt1033889

Either there is something else in your code that is common to both problems and you aren't showing us, or - as I suggested - it's a DB problem. Start by replacing "Hire_Date" with GETDATE() in your code and see if it goes away. If it does, it;s your DB.
If it doesn't then look at the rest of your code.
Richard MacCutchan 30-Dec-19 6:24am    
Do you wake up screaming in your garage at night?
OriginalGriff 30-Dec-19 6:32am    
No, but I probably would if I had a garage ... :laugh:

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900