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

DateTime Problem

I have a sql field called OrderTime.. smalldatetime in SQL 2000 length 4

I have the following in my code:

ffSql.OrderTime = Now.ToString("hh:mm:ss tt")

When I try to insert this into my table. If I replace the top with

ffSql.OrderTime = Today
instead of
ffSql.OrderTime = Now.ToString("hh:mm:ss tt")

What I want is to place the time into the field not the date and time.

Can someone help?

Nov 21 '05 #1
2 923
Bryan,

Especially for globalization it is better not to use your kind of code,

In my opinion is better to use something as
Dim mydate As DateTime = New Date(1900, 1, 1, Now.Hour, Now.Minute,
Now.Second)

(As far as I know has the datatable no "smalldatetime" only "datetime",
however when I wrong in that let somebody correct me?).

I hope this helps,

Cor
"Bryan"
I have a sql field called OrderTime.. smalldatetime in SQL 2000 length 4

I have the following in my code:

ffSql.OrderTime = Now.ToString("hh:mm:ss tt")

When I try to insert this into my table. If I replace the top with

ffSql.OrderTime = Today
instead of
ffSql.OrderTime = Now.ToString("hh:mm:ss tt")

What I want is to place the time into the field not the date and time.

Can someone help?

Nov 21 '05 #2
Another choice, if storing a date bothers you, is to store time as an
integer. For example, numbers of seconds past midnight.

Dim d As DateTime = Now
Dim ts As TimeSpan = d.TimeOfDay
Dim NumOfSecs As Integer = ts.TotalSeconds

Greg

"Cor Ligthert" <no**********@planet.nl> wrote in message
news:Od**************@TK2MSFTNGP15.phx.gbl...
Bryan,

Especially for globalization it is better not to use your kind of code,

In my opinion is better to use something as
Dim mydate As DateTime = New Date(1900, 1, 1, Now.Hour, Now.Minute,
Now.Second)

(As far as I know has the datatable no "smalldatetime" only "datetime",
however when I wrong in that let somebody correct me?).

I hope this helps,

Cor
"Bryan"
I have a sql field called OrderTime.. smalldatetime in SQL 2000 length 4

I have the following in my code:

ffSql.OrderTime = Now.ToString("hh:mm:ss tt")

When I try to insert this into my table. If I replace the top with

ffSql.OrderTime = Today
instead of
ffSql.OrderTime = Now.ToString("hh:mm:ss tt")

What I want is to place the time into the field not the date and time.

Can someone help?


Nov 21 '05 #3

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

Similar topics

4
by: Mingus Tsai | last post by:
Hello- please help with unpickling problem: I am using Python version 2.3.4 with IDLE version 1.0.3 on a Windows XPhome system. My problem is with using cPickle to deserialize my pickled...
2
by: Rey | last post by:
Howdy all. My problem deals w/inserting nulls into database (SQL Svr 2K) for the datetime fields activityDate and followUpDate where nulls are allowed. >From the web form, the user can type...
8
by: Alan Silver | last post by:
Hello, I have a custom control that displays the date and time. I currently have properties for the day, month, year, hour and minute, which have to be set separately. This is inefficient. I...
5
by: I am Sam | last post by:
I have created this DateTime object and instanced it I think correctly DateTime myClubNow1=new...
9
by: Phil B | last post by:
I am having a problem with a datetime from a web services provider The provider is sending the following SOAP response <?xml version="1.0" encoding="utf-8"?> <soap:Envelope...
3
by: pranesh.nayak | last post by:
I'm facing an error:"String was not recognized as a valid DateTime" whille accessing DateTime from webservice. And when I try to set DateTime to the same webservice it fails with error:"Date...
6
by: JFieseler | last post by:
Hi all, in a huge project i have the following problem. I create an object which contains many private members (i know that this is not correct, but it is a single use migration program). The...
5
by: iulian.ilea | last post by:
Is correct to have a varchar field and insert dates of type dd/mm/yyyy into it? I choose this method because I have an application that runs on more than one server. So, if I used a datetime field...
4
by: =?Utf-8?B?QmFidU1hbg==?= | last post by:
Hi, I have a GridView and a SqlDataSource controls on a page. The SqlDataSource object uses stored procedures to do the CRUD operations. The DataSource has three columns one of which -...
4
by: =?Utf-8?B?c2lwcHl1Y29ubg==?= | last post by:
Hi I am having a problem formatting a string when the time is in format hh.mm.ss - used in Europe Parse seems ok when the date uses "/" or "." as seperator but I get an exception when time...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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.