I have a field for time, 24 hour format as hhmmss, that may have 5 or 6 characters based on the hour of the day. I need the hour value only in a new column. I am trying to use an IF statement in a new column to say that if LEN([CTIME]=5, then LEFT([CTIME],1) elseif LEN([CTIME]=6, then LEFT([CTIME],2). Having trouble writing the statement, any help would be appreciated
Hi,Hello, this does not work as it is a numeric string, either 65215 which would mean 6:52:15 AM or 185215 which would mean 6:52:15 PM. Since it is just a 5 or 6 digit numeric string I am working with, I an just trying to grab the first character (if 5 digit) or first two if a 6 digit string.
Am 19.09.2020 um 22:42 schrieb Scott Sabo:
I have a field for time, 24 hour format as hhmmss, that may have 5 or 6 characters based on the hour of the day. I need the hour value only in a new column. I am trying to use an IF statement in a new column to say that if LEN([CTIME]=5, then LEFT([CTIME],1) elseif LEN([CTIME]=6, then LEFT([CTIME],2). Having trouble writing the statement, any help would be appreciatedThe format of a field is usually uninteresting, because it only concerns
the representation. If the field is of type Date, the Hour(myTime)
function can be used to determine the hour.
Ulrich
On Saturday, September 19, 2020 at 4:01:32 PM UTC-7, Ulrich M%ller wrote:
Hi,Hello, this does not work as it is a numeric string, either 65215 which would
Am 19.09.2020 um 22:42 schrieb Scott Sabo:
I have a field for time, 24 hour format as hhmmss, that may have 5 or 6 >>> characters based on the hour of the day. I need the hour value only in a >>> new column. I am trying to use an IF statement in a new column to say that >>> if LEN([CTIME]=5, then LEFT([CTIME],1) elseif LEN([CTIME]=6, thenThe format of a field is usually uninteresting, because it only concerns
LEFT([CTIME],2). Having trouble writing the statement, any help would be >>> appreciated
the representation. If the field is of type Date, the Hour(myTime)
function can be used to determine the hour.
Ulrich
mean 6:52:15 AM or 185215 which would mean 6:52:15 PM. Since it is just a 5 or 6 digit numeric string I am working with, I an just trying to grab the first character (if 5 digit) or first two if a 6 digit string.
I have a field for time, 24 hour format as hhmmss, that may have 5 or 6 characters based on the hour of the day. I need the hour value only in a new column. I am trying to use an IF statement in a new column to say that if LEN([CTIME]=5, then LEFT([CTIME],1) elseif LEN([CTIME]=6, then LEFT([CTIME],2). Having trouble writing the statement, any help would be appreciated= LEFT(CTIME,LEN(CTIME)-4)
Hi Scott,Mike, this worked great! I did find a few instances though in my table where I have a 4 digit number, just minutes and seconds because the record created between midnight and 1 AM. Any idea how to account for these in the code above and return an hour value of zero?
You could use Left$(CTIME,Len(CTIME)\3).
The backward slash has to be used as the divide operator to give an integer result; 6\3=2, 5\3=1.
Mike P.
20/9/20
On Sunday, September 20, 2020 at 2:45:43 AM UTC-7, Mike P wrote:Try
Hi Scott,
You could use Left$(CTIME,Len(CTIME)\3).
The backward slash has to be used as the divide operator to give an integer result; 6\3=2, 5\3=1.
Mike P.Mike, this worked great! I did find a few instances though in my table where I have a 4 digit number, just minutes and seconds because the record created between midnight and 1 AM. Any idea how to account for these in the code above and return an hour value of zero?
20/9/20
On Sunday, September 20, 2020 at 2:45:43 AM UTC-7, Mike P wrote:
Hi Scott,Mike, this worked great! I did find a few instances though in my table where I have a 4 digit number, just minutes and seconds because the record created between midnight and 1 AM. Any idea how to account for these in the code above and return an hour value of zero?
You could use Left$(CTIME,Len(CTIME)\3).
The backward slash has to be used as the divide operator to give an integer result; 6\3=2, 5\3=1.
Mike P.
20/9/20
On Saturday, September 19, 2020 at 4:01:32 PM UTC-7, Ulrich M||ller wrote:
Hi,Hello, this does not work as it is a numeric string, either 65215 which would mean 6:52:15 AM or 185215 which would mean 6:52:15 PM. Since it is just a 5 or 6 digit numeric string I am working with, I an just trying to grab the first character (if 5 digit) or first two if a 6 digit string.
Am 19.09.2020 um 22:42 schrieb Scott Sabo:
I have a field for time, 24 hour format as hhmmss, that may have 5 or 6 characters based on the hour of the day. I need the hour value only in a new column. I am trying to use an IF statement in a new column to say that if LEN([CTIME]=5, then LEFT([CTIME],1) elseif LEN([CTIME]=6, then LEFT([CTIME],2). Having trouble writing the statement, any help would be appreciatedThe format of a field is usually uninteresting, because it only concerns
the representation. If the field is of type Date, the Hour(myTime)
function can be used to determine the hour.
Ulrich
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 59 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 25:30:55 |
| Calls: | 810 |
| Files: | 1,287 |
| Messages: | 196,037 |