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
2 answers

Division gives wrong answear

This is a simple problem of calculating the min number of coins needed to give the change, given a N value. The division 0.04/0.01 gives 3, why? #include #include #include int MinQtdCoins(float N, float coins[], int…
Roni Castro
  • 1,968
  • 21
  • 40
0
votes
0 answers

Truncating HTML in Expressjs

I am looking to truncate the html on my index page by 100 characters and use a trailing "..." and I'm trying to figure out the best way to do that. Right now, I'm trying to use the package, nodejs-html-truncate, but running into an issue using it.…
cphill
  • 5,596
  • 16
  • 89
  • 182
0
votes
0 answers

Complex truncation in a UILabel

Is there an easy way to truncate a UILabel like if you used Truncate Head and Truncate Tail simultaneously? For example I would like to truncate this sentence: "An example sentence to truncate" like that: "… sentence to…" Note: My code is in…
arniotaki
  • 2,175
  • 2
  • 23
  • 26
0
votes
1 answer

Truncate chars with a read more link that when clicked honors the paragraph tags using jQuery

Please see fiddle. You will notice one div tag with two paragraph tags in it. I'd like the read more to work as it is currently but when you click the read more link it shows the text with the html. Currently it seems to strip the

tags but I…

Devnsyde
  • 1,297
  • 1
  • 13
  • 34
0
votes
2 answers

Show First Post in Full, Followed by Truncated Posts

I am trying to write a custom default loop for my blog that will display the first post in full, then have the following posts appear in truncated format with a thumbnail of featured image. I have tried everything I can think of, but cannot figure…
0
votes
0 answers

Truncate decimal for MySql Command

I want to use Truncate command with Select * query . I am thinking if something like a nested query is applicable just to determine if the returned column is a decimal value or not and apply truncate (2 decimal point) to it. A random version would…
Being Coder
  • 127
  • 2
  • 10
0
votes
1 answer

Truncate TinyMCE content in Rails 4

Before I used <% = truncate (@article.content,: length => 100)%> to truncate the content and it worked. Now I use TinyMCE I tried <% = truncate (@article.content.html_safe,: length => 100)%> but the contents are not truncated.
Guillaume
  • 1,437
  • 2
  • 15
  • 17
0
votes
1 answer

truncate filter to shorten URL

I have an ng-repeat that displays a bunch of long url paths in an input text box.
the paths looks like this endpoint:8000/foo/foo/foo/charlie1.file I would just like…
Garuuk
  • 2,153
  • 6
  • 30
  • 59
0
votes
1 answer

Truncate dynamic string javascript

I am using the instafeed.js plugin to dynamically generate a photo feed. I'd like to truncate the photo comments to 140 characters or so, but I'm having issues doing it. I'm generating my markup via the instafeed script, and it is putting the photo…
eloist
  • 465
  • 3
  • 10
  • 22
0
votes
2 answers

SQL Column will not allow entry after being altered

I have a SQL table that has a column "Stamp" the was originally setup as nchar(10). The data that was entered in this field was only 9 characters long (ie. XX111.jpg) However, I have changed the format of the data being entered. It is now…
Red_Phoenix
  • 482
  • 6
  • 22
0
votes
1 answer

Setting NSLineBreakByTruncatingHead has no effect

I have the following lines of code: textView.textContainer.maximumNumberOfLines = 10; textView.textContainer.lineBreakMode = NSLineBreakByTruncatingHead; [textView setText:@"1\n2\n3\n4\n5\n6\n7\n8\n9\n10\n11"]; No matter what I set the…
Timothy Swan
  • 623
  • 3
  • 9
  • 21
0
votes
0 answers

HttpServletRequest.getParameter() truncates the value sent through jQuery.ajax

I am having an issue when I sent data via POST using jquery.ajax and try to read the value from the HttpServletRequest in java. I am using jdk6 jboss-4.0.3 Struts 1 and for ajax I am using GSON and jquery in the client side Here is my code : JSP …
0
votes
4 answers

Truncate all values in a flat array to n characters

How can I limit the character length of all string inside an array? Like chunk_split ( $string, 10 ); $array = array( "foo" => "bar", "bar" => "foofoofoofoofoofoofoo", "name" => "name34234242224" ); I do not want more than 10 characters…
Hareesh
  • 6,770
  • 4
  • 33
  • 60
0
votes
4 answers

java converting int to short

I am calculating 16 bit checksum on my data which i need to send to server where it has to recalculate and match with the provided checksum. Checksum value that i am getting is in int but i have only 2 bytes for sending the value.So i am casting int…
changed
  • 2,103
  • 8
  • 36
  • 56
0
votes
1 answer

Select data within current week and a certain timestamp

i faced a challenge of a SQL-Selection which should provide Date from the current week AND the period of time between 05:00 and 22:00. (So from this weeks Monday-Sunday the data between 5:00 and 22:00) I searched for other questions in that…
Kyrill
  • 29
  • 1
  • 4