Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

About Datetime type??

Posted on 1998-09-21
2
Medium Priority
?
205 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
[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 7

Accepted Solution

by:
spiridonov earned 100 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Windocks is an independent port of Docker's open source to Windows.   This article introduces the use of SQL Server in containers, with integrated support of SQL Server database cloning.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.

671 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