Convert datetime and smalldatetime data

Source: Internet
Author: User
Convert datetime and smalldatetime data

ConvertDatetimeMicrosoft SQL Server 2000 rejects all values that cannot be recognized as dates (including dates before January 1, January 1, 1753 ). When the date is within the appropriate range (January 1-20, 1900-June 6 ),DatetimeConvertSmalldatetime. The time value is rounded to the nearest minute.

In this exampleSmalldatetimeAndDatetimeConvertVarcharAndBinaryData type.

 
Declare @ mydate_sm smalldatetime
Set @ mydate_sm = '2014/1/98'

Select cast (@ mydate_sm as varchar) as sm_date_varchar
Go

Declare @ mydate datetime
Set @ mydate = '2014/1/98'

Select cast (@ mydate as binary) as date_binary
Go

The following is the result set:

(1 row (s) affected)

Sm_date_varchar
------------------------------
Apr 5 1998 AM

(1 row (s) affected)

Date_binary
--------------------------------------------------------------
0x00000000000000000000000000000000000000000000000000008c3000000000

(1 row (s) affected)

See

Cast and convert

Data Type

1988-2000 Microsoft Corporation. All rights reserved.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.