| |
|
If this is your first visit, be sure to check out the FAQ by clicking the link above.
You may have to register before you can post: click the register link above to proceed.
To start viewing messages, select the forum that you want to visit from the selection below.
|
 |

07-14-08, 08:02
|
|
Registered User
|
|
Join Date: Jul 2008
Posts: 4
|
|
|
first 4 number from BIGINT filed
|
|
Hello all,
I have 1 table in that 3 fields, and 3rd filed is INTIME and data_type is BIGINT
i am fire one query as follows:
select INTIME from table_name where ....
then Output =102390
But I want Output is 1023 i.e. only first 4 number
thanks in Advanced.
with warm Regards
Deepak
--;--;<@
|
|

07-14-08, 09:09
|
|
Registered User
|
|
Join Date: Jan 2003
Posts: 3,575
|
|
substr(char(intime),1,4)
Andy
|
|

07-14-08, 09:12
|
|
:-)
|
|
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
|
|
|
|

07-14-08, 09:13
|
|
:-)
|
|
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
|
|
Don't even need the int(), really.
|
|

07-14-08, 09:16
|
|
Registered User
|
|
Join Date: Jul 2008
Posts: 4
|
|
|
Thanks
|

07-14-08, 09:17
|
|
Registered User
|
|
Join Date: Jan 2003
Posts: 3,575
|
|
Quote:
|
Originally Posted by n_i
Or int(intime/100)
|
This will only work if the bigint is between 100000 and 999999. Any other numbers it will fail.
Andy
|
|

07-14-08, 10:32
|
|
:-)
|
|
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
|
|
True, but we're not dealing with just any numbers here: these are time values represented as numbers, if I understand the OP correctly, so the values will always be between 000000 and 235959
|
|

07-14-08, 10:43
|
|
Registered User
|
|
Join Date: Jan 2003
Posts: 3,575
|
|
Quote:
|
Originally Posted by n_i
True, but we're not dealing with just any numbers here: these are time values represented as numbers, if I understand the OP correctly, so the values will always be between 000000 and 235959
|
If this is true, then it will fail for all times prior to 10 AM. This is 41% of the day.
Andy
|
|

07-14-08, 11:14
|
|
:-)
|
|
Join Date: Jun 2003
Location: Toronto, Canada
Posts: 4,449
|
|
Well, I might have misunderstood the problem. I assumed that the value in INTIME represents time in the format of HHMMSS, and Mr. Deepak wants to extract just hours and minutes. If that's the case my approach would work correctly for any value.
However, if the time representation is somehow different, the SUBSTR() would be the right approach.
|
|

07-14-08, 11:21
|
|
Registered User
|
|
Join Date: Jan 2003
Posts: 3,575
|
|
The values are stored in a bigint. So 1 AM would be 10000, not 010000 since there are no "leading zeros" on integer data types. But if the values in the field are indead supposed to be time values in the format of hhmmss and the OP does want just the hhmm portion, then dividing by 100 would work.
Andy
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|