Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

ASP.NET Forum


You are currently viewing our ASP.NET Forum as a guest. Please register to participate.
Login



Reply
Insert Time into datetime
Old 03-03-2006, 04:52 AM Insert Time into datetime
Skilled Talker

Posts: 95
Trades: 0
Hi,

I'm trying to insert '09:00' into a table in my database.
the field is in datetime format.

When i insert '09:00' everything seems fine untill i check the database where the result of the insert isdisplayed as 01/01/1900 09:00:00

no i'm not to bothered about the time having hh:mm:ss but i really really dont want to have the date before it.

does anyone know how to just insert the time with out the date?
higginbt is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-03-2006, 06:52 AM Re: Insert Time into datetime
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Actually you can't. Dates in a database are stored as a numeric value. The number preceding the DP is the date (number of days after 01/01/1900) and the number following is the time code (in mS).

Use FormatDateTime(Date,Format) to display it
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 04-16-2006, 11:57 AM Re: Insert Time into datetime
sherkhan's Avatar
Skilled Talker

Posts: 56
Trades: 0
yes higginbt You cant have detailed time in database
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

sherkhan is offline
Reply With Quote
View Public Profile Visit sherkhan's homepage!
 
Old 04-16-2006, 03:09 PM Re: Insert Time into datetime
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
You can!

just store it as a string field
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 04-17-2006, 05:24 PM Re: Insert Time into datetime
phpcurious's Avatar
Junior Talker

Posts: 1
Trades: 0
i tried that once. I stored it in the database as a string but when I need it for sake of comparison, i couldn't get an accurate result. it actually depends on the situation.
phpcurious is offline
Reply With Quote
View Public Profile
 
Old 04-17-2006, 05:53 PM Re: Insert Time into datetime
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,517
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
if you store the value as a string and need to do comparisons you have to then cast the string into a datetime value before the compare.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is online now
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Insert Time into datetime
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.18405 seconds with 12 queries