Questions tagged [truncate]

Data truncation is the automatic or deliberate shortening of data. A string, decimal number, or datestamp can be truncated to a shorter value. A data stream (such as a file or record set) can be truncated when either the entirety of the data is not needed or when it will be stored in a location too short to hold its entire length. No rounding occurs when numbers are truncated.

Data truncation may occur automatically, such as when a long string is written to a smaller buffer, or deliberately, when only a portion of the data is wanted. The truncation principles can be used in several different ways.

###Function Calls

Many data handling programs have built in methods or functions to handle truncation. Syntax will vary, but the principles are the same. Examples include:

  • Strings: TRUNC("This is a string.", 12) = This is a st
  • Decimals: TRUNC(3.14159, 2) = 3.14 or floor(3.14159) = 3
  • Dates: TRUNC(#7/4/2017 23:45#) = #7/4/2017 00:00#

###SQL Statement

In SQL, the TRUNCATE TABLE statement removes all rows from a table without invoking any triggered actions. The result of this operation quickly removes all data from a table, typically bypassing a number of integrity enforcing mechanisms. It was officially introduced in the SQL:2008 standard. In the SQL standard TRUNCATE TABLE is defined as a data manipulation language (DML) feature but database vendors often classify it as DDL for their own implementation-specific reasons.

The TRUNCATE TABLE mytable statement is logically (though not physically) equivalent to the DELETE FROM mytable statement (without a WHERE clause).

Datestamp values

Datestamps can be truncated. 2009-02-09 09:41:22 can be truncated, for example, to the:

  • year 2009-01-01 00:00:00
  • month 2009-02-01 00:00:00
  • day 2009-02-09 00:00:00
  • hour 2009-02-09 09:00:00

Related tags

References

Function Calls

SQL Statements

1585 questions
0
votes
1 answer

Opencart PayPal Express Error 18112

When we have a lot of product options in opencart, it causes the description passed through to paypal express to be longer than 127 characters. Because of this, when we return to the cart to confirm the order, we get error 18112 - "The value of…
0
votes
3 answers

NSString is being truncated

In my app I am using a webservice that sign a document. I have to send the documento in base64format inside the SOAP call. The problem is that when I try to send a big document like a 11mb one, the base64 (stored in a NSString) is to large and the…
javiazo
  • 1,892
  • 4
  • 26
  • 41
0
votes
1 answer

MySQL - How can I group numbers into 50 increment

I have a table that has a set of integers: i.e. 1, 2, 4, 50, 399, 600, 1245 etc. I need to rank these numbers but with 50 increment as the range. So the number will be truncated to the 0, 50, 100, 150, 200, 250, etc. The outcome will look like…
PMa
  • 1,751
  • 7
  • 22
  • 28
0
votes
1 answer

Why does Hyperion's Trunc(date) return large number?

I am working with Hyperion and I have never used it before about two weeks ago. Someone else set up a .bqy file to get certain columns from a DB. He has one column with this formula in it: Trunc(date) where date included the date and time. What that…
HighHopes
  • 2,014
  • 3
  • 23
  • 33
0
votes
1 answer

Silverlight IsolatedStorage: Delete not working, Truncate leaving blank space

I'm using IsloatedStorage in a Silverlight app to log information on the client, and I added a function to clear the log file. However, I have had problems with the two approaches I tried: Approach one: use…
Donakello
  • 1
  • 1
0
votes
2 answers

Extract plain text excerpt from HTML

I have @Html.Raw(Model.Content) in a razor page, I want to extract excerpt (plain text) truncated at word boundary near to 232-240 characters, followed by .... Is there any helper for all this? Something equivalent to Ruby on Rail's truncate_html…
Annie
  • 3,090
  • 9
  • 36
  • 74
0
votes
1 answer

Why is my data being truncated?

I'm relatively new to MySQL/SQL and this is my first post on this site, so I apologize if I phrase this question poorly. I saved a copy of my .xlsx file as a .csv file. I am trying to load data from that .csv file into a table. I get the following…
user2205916
  • 3,196
  • 11
  • 54
  • 82
0
votes
1 answer

limit to the number of digits

my project is to create a program that will test whether a number is prime or not. the code is ready. but when i enter a 19 digit prime for example, the code immediately outputs "composite". i'm quite sure it is because it treats the last few digits…
0
votes
1 answer

Restkit truncate db before core data mapping

i'm using restkit to map a json with core data i need to call a routine every time the user launch the app. if the server has updated data to send, i need to download them, truncate my table and insert the data in the table, if the server sends me…
Gianluca
  • 2,379
  • 3
  • 25
  • 41
0
votes
0 answers

Truncating HTML 'Browse' filename

I have a separate PHP file containing the logic and form code for an upload script I written. I have included it into a div on my admin page and I have it set to float: right. However, when I select a file with an exceptionally long filename, it…
Dave Melia
  • 307
  • 2
  • 5
  • 17
0
votes
1 answer

How to resize/lengthen/truncate a file and leave more room at the beginning?

One of the side uses of ftruncate() is that we can resize a file by just sticking zeros onto the end of the file assuming that you request a new file size larger than the original. This seems like a low cost solution to resizing a file since it…
Brett
  • 4,066
  • 8
  • 36
  • 50
0
votes
0 answers

(chrome.socket.read) My returned ArrayBuffer() is getting truncated (cut off)

I am using Chrome Apps to do a programming assignment for class and the ArrayBuffer() returned from the callback of chrome.socket.read() keeps truncating a >3 kb POST message at 1 kb. like this: POST / HTTP/1.1 Host: 127.0.0.1:8081 Connection:…
0
votes
1 answer

Trigger to Truncate then Insert rows

Everyday, some rows will be inserted into a SQL Server Table (T_PAST). These rows will be records from the past (ie August 1, 2013) as well as records that are in the future (ie January 1, 2014). I want to leave the past dated records in the table…
user2852426
  • 1
  • 1
  • 3
0
votes
0 answers

Trying to use shorten the text output using truncate smarty tag in PHP 5.4.19

trying to use {$articleTitle|truncate:30:""} to shorten the text output its working in localhost correctly but not working in server with PHP 5.4.19 am unable to find solution. I think there is no problem with code problem in server. any…
mahi2406
  • 17
  • 5
0
votes
3 answers

How to properly truncate a double

How to properly truncate a double in Java, so for example 1.99999999999999999 is always truncated to 1 and not rounded upto 2 as is the case in the sample below. double d1 = 1.999999999999999999; double d2 = 1.0; long i1 =…
volting
  • 16,773
  • 7
  • 36
  • 54