Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 datetime datatype

Author  Topic 

jobby
Starting Member

4 Posts

Posted - 2005-08-22 : 06:16:31
Hi all.

I'm using foxpro and I'm completely new to SQL. I'm trying to create a database into which I need to enter a time field. I've read around on the net that the only way to do this is using a datetime datatype but I can't find anywhere that explains the format I use to INSERT INTO my tables.

Anyone help?

*EDIT* I actually just want to enter the time and not the date and the time, I have read it is possible to do this using a convert but I'm happy enough to have the date and the time as I don't want to overcomplicate anything at this stage.

gpl
Posting Yak Master

195 Posts

Posted - 2005-08-22 : 06:25:16
Jobby
Looking at BOL (Books Online - it comes with SQL server and has nearly everything you need) it mentions in the convert functions, this date formatter.
8 - hh:mm:ss

If you have a string value for your time and convert it to a datetime it will default the date part to 01/01/1900

eg
Update MyTable
Set MyStartTime=Convert(Datetime, '09:10:30', 8)
Where StaffID=@InputStaffID

Hope this helps you
Graham

Go to Top of Page

jobby
Starting Member

4 Posts

Posted - 2005-08-22 : 06:29:12
Sorry Graham, I don't mean to sound ungrateful but that went way over my head.

I have a table:

CREATE TABLE RACE ;
(RaceNo INT(2) PRIMARY KEY, NameOfRace CHAR(35) NOT NULL, TimeOfRace T, ;
RaceDistance FLOAT(3) NOT NULL, MeetingNo INT(2) NOT NULL ;
FOREIGN KEY MeetingNo TAG MeetingNo REFERENCES MEETING)

and I need to know how to do the

INSERT INTO RACE VALUES('TimeOfRace' field)

Apologies if you have already explained this in plain english, I'm a newb.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-22 : 06:38:30
>>I'm using foxpro and I'm completely new to SQL

This is SQL Server Forum
Try this

INSERT INTO RACE(TimeOfRace) VALUES('TimeValue')


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

jobby
Starting Member

4 Posts

Posted - 2005-08-22 : 06:45:54
SQL is SQL is it not???

When you say ('Time Value') what format would you suggest?

A simple 'HH:MM'?

Also I thought you had to enter a date aswell? please correct me if I'm wrong.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-22 : 06:57:57
Your table structure
quote:
CREATE TABLE RACE ;
(RaceNo INT(2) PRIMARY KEY, NameOfRace CHAR(35) NOT NULL, TimeOfRace T, ;
RaceDistance FLOAT(3) NOT NULL, MeetingNo INT(2) NOT NULL ;
FOREIGN KEY MeetingNo TAG MeetingNo REFERENCES MEETING)

does not seem to of SQL Server 2000
Do you want to create the same structure in SQL Server?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

jobby
Starting Member

4 Posts

Posted - 2005-08-22 : 07:04:41
Sorry I assumed that SQL was a generic language that was similar if not the same on all platforms.

I do not wish to create the same structure in SQL server. I must use FoxPro.

I suppose this is the wrong place to ask then.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-08-22 : 07:22:15
>>I do not wish to create the same structure in SQL server. I must use FoxPro.

Post this question at Foxpro Forums


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -