DateTime Problem

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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?
 
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"
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top