473,848 Members | 1,788 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to convert datetime from text/char to datetime

Hi,

I have a text file that contains a date column. The text file will be
imported to database in SQL 2000 server. After to be imported, I want
to convert the date column to date type.

For ex. the text file look like

Name date
Smith 20003112
Jennifer 19991506

It would be converted date column to ydm database in SQL 2000 server.
In the table it should look like this

Name Date
Smith 2000.31.12
Jennifer 1999.15.06

Thanks in advance

- Loi -
Jul 20 '05 #1
1 67396
Loi,

If you want to store the data as type datetime, it will not "look like"
anything in the table. However, you can make it look however you
want when you select the results. Date values are stored as bits, not
as formatted character strings. The yyyy.dd.mm format is not one of
the numbered formats to use with convert(), so you will need to select
your datetime value and use string functions to format it. Try this:

select convert(char(4) ,[date],112) + convert(char(5) ,[date],4) from
yourTable

Steve Kass
Drew University

Loi Tan Vo wrote:
Hi,

I have a text file that contains a date column. The text file will be
imported to database in SQL 2000 server. After to be imported, I want
to convert the date column to date type.

For ex. the text file look like

Name date
Smith 20003112
Jennifer 19991506

It would be converted date column to ydm database in SQL 2000 server.
In the table it should look like this

Name Date
Smith 2000.31.12
Jennifer 1999.15.06

Thanks in advance

- Loi -


Jul 20 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

19
7303
by: Lauren Quantrell | last post by:
I have a stored procedure using Convert where the exact same Convert string works in the SELECT portion of the procedure but fails in the WHERE portion. The entire SP is listed below. Specifically, I have a problem with this portion in the WHERE clause: DATEADD(Day,tblMyEventTableName.ReminderDays, @DateNow) Between CONVERT(smalldatetime,str(DATEPART(Month, @DateNow)+1) + '/' + str(DATEPART(Day, tblMyEventTableName.TaskDateTime)) + '/'...
1
2232
by: Google Jenny | last post by:
Precisely, here's what I need: When I run getdate(), I get, for example: August 9 2004 5:17 P.M. I want to turn the date portion into: 8/9/2004 format and update one column with it
15
6994
by: Dan S | last post by:
My application asks the user to enter in a date - in the mm/dd/yyyy format. Is there any quick and easy way to verify the date the user enters is formatted correctly? Right now I'm calling DateTime.Parse() and catching the FormatException but it seems this is a bit inefficient - catching the exception that is. There is some pretty obvious delay while it traces back up the call stack. Is there a better way? Something that returns a bool...
11
3823
by: jguilford | last post by:
I have created a SQL Stored Procedure that uses a Case statement to determine the Order By. For one of the Case statements I am trying to turn a Char field into Datetime in for the Order By, however I can not get it to work. Can someone please take a look and my code below and tell me what I am doing wrong. Thank you. ORDER BY CASE WHEN @SortBy = 'dttm_stamp' THEN dttm_stamp End, CASE WHEN @SortBy = 'Event_Date1' THEN...
8
13040
by: Assimalyst | last post by:
Hi i have a value entered into an asp text box, procedureDateTxtBx.Text, thet has the format dd/MM/yyyy. I need to convert this into a format recognisable by SQL server in order to properly query the database. I've tried a few DateTime.Parse methods but can't get any to work. The format of these values in the database is yyyy-MM-dd hh:mm:ss.000
17
71504
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
3826
by: izziy | last post by:
Our legacy DB has a bad column which stores a date value as char(8), it has a format like 'MMDDYYYY'. I am creating a report to report this particular date and also use this date to specify a range. I tried using this SELECT Convert(datetime,(substring(c.dateofreceipt,5,4)+'-'+substring(c.dateofreceipt,1,2)+'-'+substring(c.dateofreceipt,3,2)), 102) as dateofreceipt in query analyzer and it works fine. But in .Net report designer,...
1
5233
by: Wes Peters | last post by:
I have a situation where I want to filter records for a given day. The field that stores the date/time uses the date() function as a default value, kind of a date/time stamp for the record. The problem is when I want to filter records for a given day instead of a date range. I use the CONVERT function to return just the date part of the field (101 as a style parameter) and compare that to a start and stop date (both being the same) and...
4
2507
by: RP | last post by:
I am using SQL Server 2005 as backend. I have a Text Box that accepts Date in the format dd-MM-yyyy. But when I attempt to insert a record, an error is displayed: Cannot convert char to DateTime .... Actually, when the text box has entry like 22-10-2005, it considers 22 as month whereas it is DD. How to convert the Text Box value to an acceptable format. I tried: DateTime.parse(txtDOB.Text,"dd-MM-yyyy")
0
9738
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10664
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10348
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9500
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7069
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5735
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5919
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4544
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3175
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.