Solved

time or date from timestamp

Posted on 2012-12-31
6
305 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
6 Comments
 
LVL 11

Accepted Solution

by:
Amar Bardoliwala earned 350 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 47

Expert Comment

by:Dale Fye (Access MVP)
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
Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

 
LVL 11

Expert Comment

by:Amar Bardoliwala
ID: 38735693
0
 
LVL 9

Assisted Solution

by:keyu
keyu earned 150 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

'Between' is such a common word we rarely think about it but in SQL it has a very specific definition we should be aware of. While most database vendors will have their own unique phrases to describe it (see references at end) the concept in common …
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now