Solved

SQL Server Problem when Converting DateTime from Float

Posted on 2006-06-14
5
591 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
  • 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 500 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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

920 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now