Solved

About Datetime type??

Posted on 1998-09-21
2
181 Views
Last Modified: 2010-03-19
I just want to know how to convert varchar type till datetime type (t.ex. 980901 till Sep 1 1998  1:59AM), so that I can use commando Datediff, or may be somebody has better idea?
0
Comment
Question by:ruisun
2 Comments
 
LVL 7

Accepted Solution

by:
spiridonov earned 50 total points
ID: 1090207
you should use  CONVERT function:
CONVERT(datetime,your_variable)
0
 

Expert Comment

by:SpaarQ
ID: 1090208
Try this:

DECLARE @mydate VARCHAR(10)
SELECT    @mydate = "980901"

SELECT @mydate = CONVERT(DATETIME, @mydate)


Result is:

Sep 1 1998 12:00AM

0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Performance is the key factor for any successful data integration project, knowing the type of transformation that you’re using is the first step on optimizing the SSIS flow performance, by utilizing the correct transformation or the design alternat…
Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
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.

760 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now