Solved

time or date from timestamp

Posted on 2012-12-31
6
309 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 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 48

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
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…

688 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