?
Solved

Like Oracle TO_DATE SQL function

Posted on 2004-08-16
2
Medium Priority
?
1,631 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 69

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

Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

Question has a verified solution.

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

I have a large data set and a SSIS package. How can I load this file in multi threading?
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
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 UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

777 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