caandal
asked on
How do Return a unique number from a datetime field in sql 2008
Hi Gurus
I am pulling my hair out. How do i return an integer that is unique based on date AND time from a date time field. The value currently in the datetime field which is called datetimsubmitted is '2010/09/03 10:18:05 AM'
It is easy to return an integer from the date only but each record needs to be uniquely identified by an integer based on date and time to the second
many thanks
Alan
I am pulling my hair out. How do i return an integer that is unique based on date AND time from a date time field. The value currently in the datetime field which is called datetimsubmitted is '2010/09/03 10:18:05 AM'
It is easy to return an integer from the date only but each record needs to be uniquely identified by an integer based on date and time to the second
many thanks
Alan
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Or the Unix timestamp, which is number of seconds from 1970-01-01 12:00am
convert(int, (convert(float, datetimesubmitted)-convert (float, convert(datetime,'19700101 ')))*24*60 *60)
convert(int, (convert(float, datetimesubmitted)-convert
ASKER
Hi VjSoft
Thanks - I was one bracket away from the right solution and then chucked it out
Alan
Thanks - I was one bracket away from the right solution and then chucked it out
Alan
convert(bigint, convert(float, datetimesubmitted)*24*60*6