473,327 Members | 1,920 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,327 software developers and data experts.

Formatting sysdate

rsrinivasan
221 100+
Hi,

When i Execute this query, I got the result as 29-MAY-07
Expand|Select|Wrap|Line Numbers
  1. select sysdate from dual;
But i want 29-MAY-2007.

What is the query for it?

Thanks,
May 29 '07 #1
5 3993
chandu031
78 Expert
Hi,

When i Execute this query, I got the result as 29-MAY-07
Expand|Select|Wrap|Line Numbers
  1. select sysdate from dual;
But i want 29-MAY-2007.

What is the query for it?

Thanks,
Hi,

It's a pretty straight forward query:
Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT TO_CHAR(SYSDATE,'DD-MON-YYYY') FROM DUAL
  3.  
  4.  
Cheers!
May 29 '07 #2
rsrinivasan
221 100+
Hi,

It's a pretty straight forward query:
Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT TO_CHAR(SYSDATE,'DD-MON-YYYY') FROM DUAL
  3.  
  4.  
Cheers!
Ok. Now it is working. But i need date type not char type. For that what to do?

Thanks,
Srinivas r.
May 29 '07 #3
chandu031
78 Expert
Ok. Now it is working. But i need date type not char type. For that what to do?

Thanks,
Srinivas r.
Hi,

You can still use it as a date field. Try inserting to_char(sysdate,'dd-mon-yyyy')
into a date field in a table and you will come to know.
Anyways the other method of changing the date format is to alter the default format in sqlplus:

Expand|Select|Wrap|Line Numbers
  1.  
  2. ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY';
  3.  
  4.  
This changed format will hold good for the current session and is generally used during file loads.

Hope this helped...
May 29 '07 #4
rsrinivasan
221 100+
Hi,

You can still use it as a date field. Try inserting to_char(sysdate,'dd-mon-yyyy')
into a date field in a table and you will come to know.
Anyways the other method of changing the date format is to alter the default format in sqlplus:

Expand|Select|Wrap|Line Numbers
  1.  
  2. ALTER SESSION SET NLS_DATE_FORMAT = 'DD-MON-YYYY';
  3.  
  4.  
This changed format will hold good for the current session and is generally used during file loads.

Hope this helped...
Hi,
When i am using to_char() function, it converts date type to char type. So im getting error in code behind.
Then i do not want to set as NLS_DATE_FORMAT = 'DD-MON-YYYY'.
Because some times i need some other format.

Plz say any other suggestion.

Thanks,
Srinivas r.
May 30 '07 #5
chandu031
78 Expert
Hi,
When i am using to_char() function, it converts date type to char type. So im getting error in code behind.
Then i do not want to set as NLS_DATE_FORMAT = 'DD-MON-YYYY'.
Because some times i need some other format.

Plz say any other suggestion.

Thanks,
Srinivas r.
Hi rsrinivasan,

I guess you are comparing this formatted date with some other date field. If yes then it makes sense to format even that field before doing the actual comparison. For example if say a date variable v_date holds sysdate and you want to compare this then you can do:

Expand|Select|Wrap|Line Numbers
  1. SELECT 1 FROM DUAL WHERE TO_CHAR(V,'DD-MON-YYYY') = TO_CHAR(SYSDATE,'DD-MON-YYYY')
  2.  
If your requirement is something else and then please do let me know.

Cheers!
May 30 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: WroteForLuck | last post by:
I am trying to write a simple SQL statement which will take a string (startdate) in the format DDMMYYYY and compare it to a date stored in an Oracle database. My SQL is as follows: <% "select...
1
by: Yaroslav K. Kravchishin | last post by:
Oracle 7.0.1 Server When I type SQL> select sysdate from dual; SYSDATE --------- 01-OCT-03 01-OCT-03 2 rows selected.
0
by: Yaroslav K. Kravchishin | last post by:
Oracle 7.0.1 Server When I type SQL> select sysdate from dual; SYSDATE --------- 01-OCT-03 01-OCT-03 2 rows selected.
3
by: Jouke Langhout | last post by:
Hello all! For quite some time now, I've got the following problem: Access won't close properly when a user closes the application. An ACCESS process stays active and that process can only be...
2
by: Colleyville Alan | last post by:
I am using Access and have embedded the ActiveX control Formula One that came with Office 2000. (ver 3.04). I have created and formatted a spreadsheet and now I want to copy the info with...
4
by: sajan | last post by:
Hi, I new to python. I'm trying to make changes to an existing python code . The code has an if condition something like if datetime(*(time.strptime(creation_date, '%d-%b-%y'))) <...
1
by: sajithamol | last post by:
What is the difference between current_date & sysdate function?
3
by: premkumarsp1 | last post by:
hi in the oracle sysdate, time is coming wrongly. THe date and time in the OS from where i am accessing oracle and in the OS where oracle is installed is correct. I want to know how to update time...
1
by: karuppiah | last post by:
Hi All, i need query,how to select last 3 month ,last 3wek,last 3 days , this last 3 month and 3 week should be friday, using sysdate from dual table, there is no exsting table, pls any one help...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.