Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change datetime to date

Status
Not open for further replies.

kernal

Technical User
Feb 27, 2001
415
US
I have a datetime field (example: 08/06/2007 9:05:06AM) that I want to change so only the date is in a select statement (so I only get 08/06/2007). How do I write the expression?

Help is appreciated.

Thanks
 
Hi dbtoo2001,

I have to use Peoplesoft query manager to write my queries and it says that I can't use FROM as part of my expression. Thanks for replying to my post. I guess I'll have to find some kind of workaround.
 
I don't know exactly how your front end works, but you don't need to select the function from a table. You just apply it to your column in the normal select list e.g.

select
column1,
column2,
to_char(date_column, 'MM/DD/YYYY') as output_date,
...
from my_table
 
The point was to 'show' you the use of the formatting method. You hadn't mentioned the use of a third party reporting tool, you asked how to do it in a select statement - I showed you how to do it in a select statement. You'll need to refer to the 'Peoplesoft query manager' manual and read up on how to do it within the contraints of that tool. Maybe this can help? I've never used it.

here's the link to oracle's date formating:
 
Hi,
Try:

select TRUNC(DateTimeField)

This returns only the DATE part..

Bear in mind that this is only a display format, the DATETIME field has an internal format defined by Oracle.



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Thanks all. I'll post another message when I've had the chance to try them (most likely, next week).
 
Thanks all. I'm getting error messages for the expressions. I decided to do a workaround. In the query manager, it has a drop down box for expression type and date is an option. I didn't want to use the drop down option because the statement has <= to the date but I'm only getting the < date data. I thought if I could actually write the expression instead of using the drop down box then it might work. I just have to enter 1 day after the date I really want (i.e. so if I want data for 08/15 then I have to enter 08/16, even though, it has <=). Thanks again for taking the time to reply to my problem.
 
Hi,
Why is there any issue with the operator ( <= ) when your question invloved formatting the DateTime field returned by your Select statement?

Is that field also used in the WHERE clause?



[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
I did have it as a field and in the where clause. Since I have a solution, I'm on to the next problem that hopefully, will be easier to solve. Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top