Solved

Like Oracle TO_DATE SQL function

Posted on 2004-08-16
2
1,585 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
2 Comments
 
LVL 69

Accepted Solution

by:
Scott Pletcher earned 250 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

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.

Question has a verified solution.

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

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

829 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