Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Administration
 Will This Query Work?

Author  Topic 

HassanChaudhry
Starting Member

2 Posts

Posted - 2012-11-23 : 18:32:13
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

39 Posts

Posted - 2012-11-23 : 18:55:24
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 - 2012-11-23 : 19:00:31
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

39 Posts

Posted - 2012-11-23 : 19:12:53
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
   

- Advertisement -