SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 Will This Query Work?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

HassanChaudhry
Starting Member

2 Posts

Posted - 11/23/2012 :  18:32:13  Show Profile  Reply with Quote
I was just doing some revision for SQL and I came across a question: Which asks the user to format the date so it displays the four figure year first then the month written in full like July and lastly the day written as a number e.g. 5

I made this Query: I can`t access my database to test it so I was just wondering that if any SQL professionals would be able to simple tell me if this would work or not?

SELECT ename,To_char(hiredate,'YYYY,MONTH'),
To_number(hiredate,'DAY')
FROM emp;

emp is table
ename is employee name column
and hiredate is obviously the hire date

thanks

Elizabeth B. Darcy
Starting Member

United Kingdom
39 Posts

Posted - 11/23/2012 :  18:55:24  Show Profile  Reply with Quote
The TO_CHAR and TO_NUMBER do not seem like they are built-in functions in Microsoft SQL Server. In SQL Server, you would format it like this:
SELECT ename, FORMAT(hiredate,'yyyyMMMMdd')
If you are indeed asking about the Oracle functions, I will defer answering that to other people who have familiarity with Oracle, which I do not possess at the moment.


________________________________________
-- Yes, I am indeed a fictional character.
Go to Top of Page

HassanChaudhry
Starting Member

2 Posts

Posted - 11/23/2012 :  19:00:31  Show Profile  Reply with Quote
quote:
Originally posted by Elizabeth B. Darcy

The TO_CHAR and TO_NUMBER do not seem like they are built-in functions in Microsoft SQL Server. In SQL Server, you would format it like this:
SELECT ename, FORMAT(hiredate,'yyyyMMMMdd')
If you are indeed asking about the Oracle functions, I will defer answering that to other people who have familiarity with Oracle, which I do not possess at the moment.


________________________________________
-- Yes, I am indeed a fictional character.




Yes I was talking about Oracle!
Go to Top of Page

Elizabeth B. Darcy
Starting Member

United Kingdom
39 Posts

Posted - 11/23/2012 :  19:12:53  Show Profile  Reply with Quote
Ah, sorry about not being able to offer you any help at all. I don't have an Oracle installation to test it out.

If I am not thoroughly mistaken, this forum is mostly about Microsoft's variation of SQL language, so there may not be many people who might be able to test that out for you. May I suggest http://www.orafaq.com/forum/ or http://www.dbforums.com/oracle/ ?


________________________________________
-- Yes, I am indeed a fictional character.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000