?
Solved

SQL Server Problem when Converting DateTime from Float

Posted on 2006-06-14
5
Medium Priority
?
621 Views
Last Modified: 2008-01-09
Dear Sir.

I have one system called Secure Perfect from GE (General Electronics) this system used for Time & Attendence, this system has its database in which this store the employee punch record, when i saw the table it show me both the Microdate and Systemdate fields as float there are some values of Date 14/06/2006

38882.375556
38882.396042
38882.397037
38882.407303

these are the punches record datetime.

when i try to convert these values from my query into user friendly date and time it gives me values with wrong date i.e.
" 2006-06-16" and punch is recorded on " 2006-06-14" and even on the evenmonitor of Secureperfect where i can watch the live punches monitoring it shows me correct date but when i want to generate report base on the data inside database i am facing a problem.

If you try to execute these command on above mention data you will find the date same like i mention show.
commands i try to execute are.

select cast(38882.375556 as datetime)

 Or

select convert(Datetime,38882.375556,101)

these both give you this data" 2006-06-16 XX:XX:XX.XX "
but these punches was record on 2006-06-14



looking forward for your reply.

Kind regards,

Zeeshan
0
Comment
Question by:altuwairqi2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 28

Expert Comment

by:imran_fast
ID: 16900820
hi Zeeshan,
the result what you are getting is correnct ie 2006-06-16
i think there might be something wrong in your punching system here how this conversion works

38882.407303

the value 38882 is the no. of days after 1900-01-01 and 407303 is the time
so if you manuall want to convert this to date then

select dateadd(day,38882,'1900-01-01')
which will give you 16 june 2006

so please verify your punching system date and server dates.
0
 

Author Comment

by:altuwairqi2
ID: 16901056
Dear Sir.

i check the database Collation it is Arabic_CI_AS now is there any way i can convert this date back to Georgian?

thanks and regards,
0
 
LVL 28

Accepted Solution

by:
imran_fast earned 2000 total points
ID: 16926451
If you are 100% sure about this then use this subtract two days from that date.

select dateadd(day,-2,convert(Datetime,38882.375556,101))

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
I have a large data set and a SSIS package. How can I load this file in multi threading?
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Suggested Courses

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question