473,388 Members | 1,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

Convert to Datetime

Hi,

I am trying to input data to a SQL server table from my source Access 2003 table. The table name is Cases. One of the columns 'DateClosed' has datetime as data type in the source database. In the input SQL I was trying to convert 'DateClosed' as follows,

CREATE TABLE [Term2000SQL].[dbo].[Cases] (
[AutoKey] int NOT NULL,
[DocketNumber] nvarchar(9),
[Aliases] nvarchar(255),
[DateReviewed] datetime,
[DateReceived] datetime,
[DateFiled] datetime,
Convert (datetime,[DateClosed],mm/dd/yyyy),
[BoxNumber] nvarchar(10),

But it keep giving me the message saying, Incorrect syntax near the keyword 'Convert'

Please help,

Thanks
Jan 14 '08 #1
3 2501
Shashi Sadasivan
1,435 Expert 1GB
You are only creating a table. at the time of creation you specify the field name and the datatype.
obviously SQL does not like any other things to be put in.

Once you create the table
Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE [Term2000SQL].[dbo].[Cases] (
  2. [AutoKey] int NOT NULL,
  3. [DocketNumber] nvarchar(9),
  4. [Aliases] nvarchar(255),
  5. [DateReviewed] datetime,
  6. [DateReceived] datetime,
  7. [DateFiled] datetime,
  8. [DateClosed] datetime,
  9. [BoxNumber] nvarchar(10), ....
then while tranferring data u can convert that field to the datetime value.

if the table is already created then you may want to alter the table to change the atatype of the column [DateClosed]
Jan 14 '08 #2
You are only creating a table. at the time of creation you specify the field name and the datatype.
obviously SQL does not like any other things to be put in.

Once you create the table
Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE [Term2000SQL].[dbo].[Cases] (
  2. [AutoKey] int NOT NULL,
  3. [DocketNumber] nvarchar(9),
  4. [Aliases] nvarchar(255),
  5. [DateReviewed] datetime,
  6. [DateReceived] datetime,
  7. [DateFiled] datetime,
  8. [DateClosed] datetime,
  9. [BoxNumber] nvarchar(10), ....
then while tranferring data u can convert that field to the datetime value.

if the table is already created then you may want to alter the table to change the atatype of the column [DateClosed]
If the table is already created on the SQL server database, the Input Data wizard will not let you modify the SQL !! Could you please explain your answer little more on how else to do the convert on transferring data?

Thanks
Jan 15 '08 #3
ck9663
2,878 Expert 2GB
If the table is already created on the SQL server database, the Input Data wizard will not let you modify the SQL !! Could you please explain your answer little more on how else to do the convert on transferring data?

Thanks
import the data into a non-existing table (or delete the existing table first). it will be uploaded with the same structure as your table in access...

then you can:
change the structure..

or

create a table and do an INSERT INTO with all the necessary conversion

or

do a SELECT cast(oldfield as newtype) as newfield into newtalbe from oldtable
drop the oldtable
sp_rename newtable, whatireallywantmynewtablenametobe

-- CK
Jan 15 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Sorisio, Chris | last post by:
Ladies and gentlemen, I've imported some data from a MySQL database into a Python dictionary. I'm attempting to tidy up the date fields, but I'm receiving a 'mx.DateTime.Error: cannot convert...
1
by: Logan X via .NET 247 | last post by:
It's official....Convert blows. I ran a number of tests converting a double to an integer usingboth Convert & CType. I *ASSUMED* that CType would piggy-back ontop of Convert, and that performance...
3
by: Vicki Carlsen | last post by:
Hi, What is the easiest way to convert a DateTime object to a long?? - And the other way back?? (For database use) Regards, Vicki
5
by: simon | last post by:
I have datetime variable: Datetime tsEndTime; Should I use (DateTime): tsEndTime=(DateTime)rdr.GetValue(15) or is better to use: tsEndTime=Convert.ToDateTime(rdr.GetValue(15))
2
by: ziggislaw | last post by:
hello how can I convert DateTime from "25.12.2005" to "2005-12-25 00:00:00.000" ? Now I have DateTime as string (I get it from <asp:label>). Thanks
5
by: Learner | last post by:
Hello, Here is the code snippet I got strucked at. I am unable to convert the below line of code to its equavalent vb.net code. could some one please help me with this? static public...
17
by: Terry Jolly | last post by:
New to C# ---- How do I convert a Date to int? In VB6: Dim lDate as long lDate = CLng(Date) In C#
1
by: Ryan Ramsey | last post by:
I am trying to convert a value returned from the date() function in php 5.0 to a format .NET can use. DateTime dt_now = DateTime.Now; DateTime dt_last = new DateTime(Convert.ToInt32(dkpLast));...
2
by: kirke | last post by:
Hi, I have a datetime column named dtDateTime. its format is "Oct 27 2006 12:00:00 " I want to group by only date part of it and count my code is $sql1="SELECT ...
7
by: groups | last post by:
This is my first foray into writing a generic method and maybe I've bitten off more than I can chew. My intent is to have a generic method that accepts a value name and that value will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.