LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (May 2010)Back to main SPSSX-L pageJoin or leave SPSSX-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Wed, 12 May 2010 17:39:43 -0400
Reply-To:     Richard Ristow <wrristow@mindspring.com>
Sender:       "SPSSX(r) Discussion" <SPSSX-L@LISTSERV.UGA.EDU>
From:         Richard Ristow <wrristow@mindspring.com>
Subject:      Re: Converting C# UTC Date/Time value
Comments: To: Mark Vande Kamp <mevk@U.WASHINGTON.EDU>
In-Reply-To:  <alpine.LRH.2.01.1005121126570.1402@hymn13.u.washington.edu >
Content-Type: text/html; charset="us-ascii"

<html> <body> At 02:26 PM 5/12/2010, Mark Vande Kamp wrote:<br><br> <blockquote type=cite class=cite cite="">I have some data where some time stamps were logged as 19-digit binary values that are readily translated by a C# function.<br><br> An example: In C# code, DateTime.FromBinary(5245773030495241607) returns 5/6/2010 12:06:46 AM.<br><br> Can anyone help me with writing SPSS syntax that will translate the 19-digit values I have into an SPSS date/time format?</blockquote><br> It's a pretty fair guess that you have an epoch-and-offset date format: that is, the number you have represents the time, in a some unit, since a chosen time in the past (the 'epoch').<br><br> (These are common now. SPSS uses seconds since midnight, October 14, 1582; Excel uses days starting with 1=1 January 1900; Unix uses seconds since midnight proleptic Coordinated Universal Time (UTC) of January 1, 1970.)<br><br> It looks like you have access to a system that will generate such time stamps for 'right now', and convert them into readable dates and times. If so, you should be able to find the time unit and the epoch: calculate difference in, say, seconds between two time-stamps, and see what the numeric difference is between the binary values.<br><br> (The unit, whatever it is, is SHORT. The HP48 calculator's unit is 1/8192 seconds, and it counts from something like 0/00/0000; and ITS count is about a ten-thousandth of that number you give.)<br><br> The unit is the important thing. You don't need the epoch <i>per se; </i>you just need the timestamp for a convenient time not too far past. Take any other timestamp, subtract, convert the result to second or whatever, and add to your 'epoch' as represented in, say, SPSS format.<br><br> <b>CAREFUL</b>, though: SPSS cannot represent 19-digit numbers exactly. (SPSS carries 53 bits, or marginally less than 16 digits.) You'll have to read in your numbers as strings and break them apart. I'll guess that the epoch was a long time ago and there are many leading digits that won't change over times you're interested in; you can strip those, read the rest as a number, and proceed as above, having stripped the same digits from the time-stamp representation of your 'epoch'.<br><br> Or, perhaps you can read your data in C#, and convert your stamps into, say, seconds since something reasonable.</body> <br> </html>

===================== To manage your subscription to SPSSX-L, send a message to LISTSERV@LISTSERV.UGA.EDU (not to SPSSX-L), with no body text except the command. To leave the list, send the command SIGNOFF SPSSX-L For a list of commands to manage subscriptions, send the command INFO REFCARD


Back to: Top of message | Previous page | Main SPSSX-L page