Link to home
Start Free TrialLog in
Avatar of fuerteventura
fuerteventura

asked on

Convert time to number in T-SQL

I'm sure this is easy - how do you convert the current date and time into a number in Transact SQL, taking into account split seconds? Quite a few digits if possible as i want to use it as an  ID on an Audit table (not a unique ID though for obvious reasons!)- thanks for looking
ASKER CERTIFIED SOLUTION
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Aneesh
Aneesh
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of fuerteventura
fuerteventura

ASKER

Many thanks for all your help, I know have further clarification on what is required - what i need is the following:

on 4th February 2008 at 11:30 and 20 seconds and 30 milliseconds I need an id such as the following:
0402200811302030

Can anyone help me get that/ I presume a datepart function may be usefull? I will be awarding points to all of the above as all answer the original question, many thanks again
SELECT REPLACE(CONVERT(VARCHAR, GETDATE() , 103),'/','')+
       REPLACE(CONVERT(VARCHAR, GETDATE(),108),':','')


SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial