Solved

SQL Server Problem when Converting DateTime from Float

Posted on 2006-06-14
5
585 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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

Introduced in Microsoft SQL Server 2005, the Copy Database Wizard (http://msdn.microsoft.com/en-us/library/ms188664.aspx) is useful in copying databases and associated objects between SQL instances; therefore, it is a good migration and upgrade tool…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.

707 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