473,467 Members | 1,680 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Convert numbers into time

3 New Member
Hi,

I am downloading data from a CAD program and data I get for time is messed up. For example 12:00 AM comes out as 0, 1:00 PM is 1300. Is there any way I can convert these numbers into a useable time format? Thanks.
Nov 17 '07 #1
3 2490
missinglinq
3,532 Recognized Expert Specialist
Based on your two samples, I assume that this is military time, being imported as a numeric datatype. Hence, for midnight, Access is converting 0000 to 0. So I think what you have to do is to look at the length of the original value and parse it into standard military/24 hour format time. From there you can use it to do your normal time calculations.

Where the time you're importing is OriginalTime and the parsed version is StandardMilitaryTime.

Expand|Select|Wrap|Line Numbers
  1. Private Sub ConvertToMilitaryTime_Click()
  2.  
  3. If Len(Me.OriginalTime) = 1 Then
  4.   Me.StandardMilitaryTime = "00:0" & Me.OriginalTime
  5. End If
  6.  
  7. If Len(Me.OriginalTime) = 2 Then
  8.   Me.StandardMilitaryTime = "00:" & Right(Me.OriginalTime, 2)
  9. End If
  10.  
  11. If Len(Me.OriginalTime) = 3 Then
  12.   Me.StandardMilitaryTime = "0" & Left(Me.OriginalTime, 1) & ":" & Right(Me.OriginalTime, 2)
  13. End If
  14.  
  15. If Len(Me.OriginalTime) = 4 Then
  16.   Me.StandardMilitaryTime = Left(Me.OriginalTime, 2) & ":" & Right(Me.OriginalTime, 2)
  17. End If
  18. End Sub
  19.  
I need too emphasize that I've been fighting a headache the size of Texas, and am having a hard time concentrating, and that I've only done limited testing of this code, so you need to run some tests on a wide range of data. I think, however, assuming the data you're importing is being formatted consistently, that this will work. I have run tests using the resultant military "times" and they do work correctly when using them in functions such as DateDiff and DateAdd.

Welcome to TheScripts!

Linq ;0)>
Nov 17 '07 #2
p543
3 New Member
Thanks for the assistance.
Nov 18 '07 #3
missinglinq
3,532 Recognized Expert Specialist
No problem, that's why we all play here!

Linq ;0)>
Nov 18 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Klaus Neuner | last post by:
Hello, I need a function that converts a list into a set of regexes. Like so: string_list = print string_list2regexes(string_list) This should return something like:
5
by: Tony Vasquez | last post by:
I want to turn the string "100,144" to numbers, to use for resizeTo(100,144) <--- here. Please advice, or post scriptlette. Thanks Tony Vasquez
3
by: R2 | last post by:
Hello Can anyone advise / help on this problem. I have a friend (brother in law) who is in the (spam) telephone fax business. He would like to convert numerous phone lists from old data bases to...
2
by: Phil Stanton | last post by:
When designing a new form or report, the Default ForeColor is often something like -2147483640 which is the colour of Windows text (possibly black) and the default backColor is -2147483643...
28
by: MLH | last post by:
The largest integer A97 can deal with is 2,147,483,647, as I understand it from HELP. I would be content to represent larger integers as strings. For example, "2147483648" would suit me fine. I...
5
by: Bob Homes | last post by:
In VB6, foreground and background colors of controls had to be assigned a single number. If you knew the RGB values for the color, you still had to convert them into the single number accepatable...
19
by: VK | last post by:
http://groups.google.com/group/comp.lang.javascript/browse_frm/thread/ b495b4898808fde0> is more than one month old - this may pose problem for posting over some news servers. This is why I'm...
28
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I convert a Number into a String with exactly 2 decimal places?...
2
by: remya1000 | last post by:
How to convert UTC formate time to local time.using vb.net. In my application in some point of the execution i need to retrieve a date,but instead of date i get some numbers,for example...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.