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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Insert Current time into integer field

Author  Topic 

mabel
Starting Member

4 Posts

Posted - 2011-08-05 : 20:10:24
Hi all,
I need to retrieve current system time and insert it into an integer field.Could any one help do this please.

Many thanks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2011-08-05 : 20:23:26
Into an integer field? In what format?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

mabel
Starting Member

4 Posts

Posted - 2011-08-05 : 20:35:46
hi
Thanks for reply if time is 8:33:00
i need to insert into integer field as 83300

quote:
Originally posted by tkizer

Into an integer field? In what format?

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog

Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2011-08-06 : 06:59:56
First question. Why?
You're setting yourself up for a lot of pain in the future when querying that column, using the time anywhere.

--
Gail Shaw
SQL Server MVP
Go to Top of Page

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-08-06 : 07:29:48
[code]INSERT INTO yourTable (yourIntegerColum)
SELECT
DATEPART(second,CURRENT_TIMESTAMP) +
100 * DATEPART (minute,CURRENT_TIMESTAMP) +
10000 * DATEPART(hour, CURRENT_TIMESTAMP);[/code]
Go to Top of Page
   

- Advertisement -