Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

SQL Server Problem when Converting DateTime from Float

Posted on 2006-06-14
5
Medium Priority
?
631 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…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
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 extract information from SQL Server on Database, Connection and Server properties

609 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