Solved

time or date from timestamp

Posted on 2012-12-31
6
307 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
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
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

Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

Suggested Solutions

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
'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 …
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

792 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