473,386 Members | 1,693 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Calculate Time

30
hi everyone, i know this is easy to others but i'm going to explode now to this. the scenario is this. i would like to trace where the time is equivalent to 1st Shift, 2nd Shift and 3rd Shift where 1st Shift = 6AM - 2PM, 2nd Shift = 2PM - 10PM and the 3rd Shift = 10PM - 6AM..

i would like to trace the shift by the time format 12HR not 24HR format. i done this using 24HR but i want to change it to 12HR. The logic i made is this, i will trace either the time is AM or PM then create some condition. some time it gives me a corrent output but others not.

this is the piece of my code:

NOTE: CurrentHour is a variable where i get the 2 digit hour and the AMPM is the format of the time wheather it is AM or PM and the Description is a variable where i where the description wheather is is 1st, 2nd, or 3rd shift. in Automation they called it Tag.

Expand|Select|Wrap|Line Numbers
  1. IF (CurrentHour >= "06"  AND AMPM == "AM")  AND
  2.     ((CurrentHour >=  "12" AND AMPM == "PM")  AND 
  3.     (CurrentHour <= "02"  AND AMPM == "PM"))THEN    
  4.     Description = "1st Shift";
  5.  
  6. ELSE
  7.     IF (CurrentHour >= "03" AND AMPM == "PM")  AND 
  8.     (CurrentHour <="10"  AND AMPM == "PM") THEN
  9.     Description = "2nd Shift";
  10.  
  11. ELSE
  12.     IF (CurrentHour >= "10" AND AMPM == "PM") AND
  13.     (CurrentHour == "12" AND AMPM == "AM") THEN
  14.     Description = "3rd Shift";
  15.  
  16. ELSE
  17.     Description = "3rd Shift";
  18.  
  19. ENDIF;
  20. ENDIF;
  21. ENDIF;
by the why the code above is what they code Wonderware a Automation Software but it seems like a VB syntax. Hope you can help me.

Thank You
Feb 7 '08 #1
3 1358
debasisdas
8,127 Expert 4TB
The semicolon and == says it is not VB 6 code.
Feb 7 '08 #2
klaydze
30
The semicolon and == says it is not VB 6 code.
helo like what i said the code above is a syntax of a wonderware software which is a Automation software but the logic is the same in vb. i just wan't to hear from you some suggestion for the logic of getting the shift in the given time.

Thank you.
Feb 8 '08 #3
Killer42
8,435 Expert 8TB
Rather than trying to deal with string values, convert to an actual time value first. Then it's much more simple.
Feb 8 '08 #4

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

Similar topics

1
by: sg_s123 | last post by:
============================================================================ 02-Feb-04 03-Feb-04 Staff Staff 0800hr- 1300hr- 1700hr- 1900hr- 0800hr- 1300hr- 1700hr- 1900hr- Number...
7
by: Tim Quon | last post by:
Hi Is there any function to get the current time so I can calculate the execution time of my code? What all is in the time.h and sys/times.h? Thanks Tim
6
by: Herrcho | last post by:
in K&R Chapter 6.3 it mentions two methods to calculate NKEYS. and points out the first one which is to terminate the list of initializers with a null pointer, then loop along keytab until the...
4
by: Qwert | last post by:
Hello, I do: Debug.WriteLine("A: " & DateTime.Now.Ticks.ToString) REM Calculate a bunch of stuff. Some loops and math functions. Debug.WriteLine("B: " & DateTime.Now.Ticks.ToString) but...
1
by: Bujji | last post by:
Hi, How to calculate Heap memory used by a process in HPUX machine (Itanium) using aCC compiler at run time ( My ultimate aim is to calculate heap memory at run-time and write it into a log...
5
by: Michael | last post by:
Hi. I need dinamically calculate input text field based on parent static TD before showing content of input. Please, advice. Michael
5
by: Beemer Biker | last post by:
I cant seem to get that date into any DateTime to make my calculation directly by subtracting "01-01-0000" from "now". After reading this:...
2
by: Lancelot | last post by:
Hello everyone. This is my first post here, but I've been looking for answer many time. I have a crazy idea in my head and since I am quite a newby to python, I am not sure where to start or if...
9
by: brendanmcdonagh | last post by:
Hi, I am designing a project for my friend as I am just a week old baby to vb and want to implement what I've learnt so far. She wants to be able to put start time, end time and lunch for each...
6
by: rrstudio2 | last post by:
I am using the following vba code to calculate the median of a table in MS Access: Public Function MedianOfRst(RstName As String, fldName As String) As Double 'This function will calculate the...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...

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.