Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

time or date from timestamp

Posted on 2012-12-31
6
Medium Priority
?
312 Views
Last Modified: 2013-01-04
Greetings,
I need  a case statement against a timestamp...
I need to return a date if the timestamp is not "today"
otherwise return a time if the timestamp is "today"

help?
Thanks
0
Comment
Question by:Evan Cutler
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 11

Accepted Solution

by:
Amar Bardoliwala earned 1400 total points
ID: 38734069
Hello arcee123,

Following should help you.

SELECT (

CASE datefield
WHEN DATE( datefield) = CURDATE( )
THEN TIME( datefield)
ELSE DATE( datefield)
END
)
FROM tbl


Thank you.

Amar Bardoliwala
0
 
LVL 48

Expert Comment

by:Dale Fye
ID: 38734392
Just to clarify.  The timestamp datatype is not a date/time.
0
 
LVL 9

Author Comment

by:Evan Cutler
ID: 38735054
Thank you Amar,
Happy New Year...
how do I format the Date and Time to make them more readible?

thanks
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 11

Expert Comment

by:Amar Bardoliwala
ID: 38735693
0
 
LVL 9

Assisted Solution

by:keyu
keyu earned 600 total points
ID: 38735738
hi,


TO_CHAR('20100901', 'MM/YY')
 
This gives the following result:
 
09/10


TO_DATE('20100901', 'YYYYMMDD')
 
This gives the following result:
 
01-SEP-10

refer this links might helps to resolve your issue....

http://www.ehow.com/how_6960278_convert-date-timestamp-oracle-sql.html

for sql i am not sure but this might works for you....

SELECT CAST('0100901' AS DATETIME)

once you have that you can easily perform other functions...
0
 
LVL 9

Author Closing Comment

by:Evan Cutler
ID: 38745096
Thanks guys.
0

Featured Post

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question