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

x
?
Solved

Like Oracle TO_DATE SQL function

Posted on 2004-08-16
2
Medium Priority
?
1,661 Views
Last Modified: 2008-03-10
I would like to know if MSQL has a function
like Oracle TO_DATE SQL function.

TO_DATE converts a string to a DATE value.

for example:

to_date('1998/05/31:12:00:00AM', 'yyyy/mm/dd:hh:mi:ssam'));


Thanks
0
Comment
Question by:vcarballo
[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
2 Comments
 
LVL 70

Accepted Solution

by:
Scott Pletcher earned 750 total points
ID: 11815316
With less flexibility, yes.  You have to use CAST or CONVERT.  CAST works if the format is a "standard" format that SQL automatically recognizes, for example:

CAST('1998-05-31 12:00:00AM' AS DATETIME)

Convert is necessary for a "non-standard" format, although no format corresponds to "yyyy/mm/dd hh:mm:ssam'.  That is what is less flexible; you ultimately have to use a format that SQL will recognize.

See Books Online for more details on CAST and CONVERT.
0
 

Author Comment

by:vcarballo
ID: 11857135
Thanks a lot

This is my way:

convert(datetime, convert(char(2), DAY(getdate())) + '/' +
                          convert(char(2), MONTH(getdate())) + '/' +
                          convert(char(4), YEAR(getdate())), 103)
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
One of the most important things in an application is the query performance. This article intends to give you good tips to improve the performance of your queries.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

597 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