-2

Presently my query returning date as 05-04-17 06:31:17.881698000 PM.

But I want to return like 20/10/201. I have reffered this link But I am unable to intigrate this query in my query as they are taking columns individually.

select * from test_Table where reg_id = ?
Community
  • 1
  • 1
Shiva Goud A
  • 322
  • 1
  • 6
  • 18

3 Answers3

3

You can simply give in the format as you like DD/MM/YYYY

select to_char(yourdate,'DD/MM/YYYY' ) from test_Table where reg_id = ?
Rams
  • 2,129
  • 1
  • 12
  • 19
0

If you insist on using your query as-is (in general, using SELECT * is not a best practice), you can change the date format for your session with the following query:

ALTER SESSION SET NLS_DATE_FORMAT = 'DD/MM/YYYY';

You can then run your query and the date should be returned in the format you want. Note that you'll have to do this with every session you start where you want the date in this format.

David Faber
  • 12,277
  • 2
  • 29
  • 40
-2

You can use the below SQL Query to Query for the Date as the format you are asking for.

SELECT CONVERT(VARCHAR(10), GETDATE(), 103) AS [DD/MM/YYYY]

You can query it directly or you can use it somewhere as variable to store it and then use it on the query you want.

Hope this help you.