473,434 Members | 1,389 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,434 software developers and data experts.

SQL Cast/Convert

347 100+
I have the following bulk insert command on my asp.net page:

Dim sqlQueryText As String = _
"BULK INSERT dialerresults " + _
"FROM '" & SavePath & "' " + _
"WITH ( FIELDTERMINATOR = ',' , ROWTERMINATOR = '\n' )"

and the following dataset that's being uploaded to a database:

,512 408 1323,steve miller,doctor stevens,20100709 1:30, 20100709 1:30,,

You can see that there are two datetime fields. What I need to do is to convert the first datetime field to just date and the second one to just time. I'm using SQL 2000 and just need to know the proper syntax to do this to add it to my asp.net page.

My database field names are as follows:

ID (primary key )
Phone
PatientName
DrName
ApptDate
ApptTime
CurrentDate (timestamp)
Result (null)

Thank you,

Doug
May 18 '10 #1
4 2368
ck9663
2,878 Expert 2GB
SQL Server does not have a date only datatype nor a time only datatype.Just datetime and smalldatetime. If you still want to, you can store them as numbers or nvarchar and handle the conversion as necessary.

Good Luck!!!

~~ CK
May 18 '10 #2
dougancil
347 100+
CK,

Perhaps I didn't make my post clear enough. I understand that there aren't date and time within SQL but what I mean to say is that I want to use convert to truncate the datetime columns to show just date and time.
May 18 '10 #3
ck9663
2,878 Expert 2GB
If you need to display it, you might want to consider handling it on your front-end instead. But if you really want your server to handle it, check out the third parameter of the CONVERT() function.

Happy Coding!!!

~~ CK
May 18 '10 #4
dougancil
347 100+
CK,

I don't need to display it, but what I'd like to do is to just throw the convert statement into my asp.net page with the sql bulk insert. I've read the documentation but there doesn't seem to be a way to convert datetime to anything. The value I would be getting the datetime in, I just want to truncate it. The value is already set as datetime in that column. Is that possible?
May 18 '10 #5

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

Similar topics

3
by: thomasamillergoogle | last post by:
Hello, I have a table that unfortunatley has a field 'DateSold' with datatype of int that SHOULD be datetime. So, I am trying to do a cast/convert. The int is stored as 20040520 (which means...
11
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,...
13
by: Jack MacRank | last post by:
Hello, I'm coding a webform application in C# (ASP.NET 1.1 SP1 with VS.NET 2003 Pro on WinXP SP2 using IIS 5.1). I created a seperate "data" class to house all the MySQL connection and sql...
7
by: Jim Bancroft | last post by:
Hi everyone, A basic one here, I think. I haven't found the pattern yet, but sometimes when I cast a variable to another type using the "C" style cast operator the compiler refuses to play...
8
by: Jarod | last post by:
Hey I have following "problem". int id = (int)SQlHelper.ExecuteScala(...) - it returns object ( which is int ) I get invalid cast. Convert.ToInt32(...) works ok. Why ? Jarod
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))
6
by: Ant | last post by:
Hi, I'm trying to find out the benefits of one type of conversion method over another. When would it be best to use casting over Converting e.g. (int)stringValue as opposed to ...
1
by: Hifni Shahzard | last post by:
Hi, I got a stored procedure, where it returns a value. But if I execute it. It gives an error as "Invalid cast from System.Int32 to System.Byte.". To make clear how do I execute this, below I'm...
4
by: dba_222 | last post by:
Dear Experts, Ok, I hate to ask such a seemingly dumb question, but I've already spent far too much time on this. More that I would care to admit. In Sql server, how do I simply change a...
19
by: tshad | last post by:
I have a value in my sql table set to tinyint (can't set to bit). I am trying to move it into a boolean field in my program and have tried: isTrue = (int)dbReader and isTrue =...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.