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

Python Syntax Truncate Error

I'm trying to set up a script that re-writes the interfaces file and eventually it will change the ip address to static, but when I run it I get an error the line that reads ' new_location_interfaces.truncate()' and it says that 'str' object has no…
Bob Jones
  • 3
  • 2
0
votes
0 answers

How to Truncate Mysql Table in Hadoop(Map-Reduce)

We are using Mysql Database for storing output in map-Reduce(hadoop). We need to Truncate the table before inserting data into it. Is there a way to do it using Map-Reduce Program.
HarshaKP
  • 159
  • 3
  • 12
0
votes
4 answers

How to truncate HTML with special characters?

I'm aware of various ways to truncate an HTML string to a certain length including/not including the HTML tags as part of the result and/or truncating while preserving whole words and whatnot. My issue, though, is if the string includes special…
WOUNDEDStevenJones
  • 5,150
  • 6
  • 41
  • 53
0
votes
2 answers

VBA for truncating data in an MS Excel cell

I have an Excel spreadsheet with some 4000 instances of data entered in a cell as (for example) =234+3455+456+876. [The data are stock market related.] It turns out I only need the first two data elements. Each datum can be anywhere from 1 to 4 or…
James
  • 1
  • 1
0
votes
1 answer

How to truncate words that are too long with CSS3?

Is there the possibility to cut off a word that runs out of a containing box (like a div or paragraph) with CSS3? The white-space: nowrap; property does not work for me because my text is written in multiple lines and white-space: nowrap; makes a…
Benny Code
  • 51,456
  • 28
  • 233
  • 198
0
votes
2 answers

Product description update issue with database

We did have a big problem with magento product description update/save for a while now. Was looking around for some solution with no success. Today i noticed that the problem was in the table “catalog_product_entity_text”. I did try to delete some…
0
votes
2 answers

Truncate file Name and and rename

I need assistance with creating a bat or VBSript that will truncate the last 34 characters in the file name then add "HCL" at the end while keeping the file extension. Here is an example: old file SMITH,JOHN_HR 100-110 Hist Certs, Licensures,…
user2709035
  • 1
  • 1
  • 1
0
votes
3 answers

Is it possible to call truncate method in rspec feature test?

I'm using Rails 3.2, Rspec 2 and capybara 2. I am truncating a string of body text in my webpage and would like to test this in my feature spec. Can someone advise how to do this because I can't seem to call truncate in my test because it keeps…
user1116573
  • 2,817
  • 4
  • 17
  • 27
0
votes
3 answers

How to left/right truncate numbers without strings (Euler #37)

As stated in problem 37 at Project Euler: The number 3797 has an interesting property. Being prime itself, it is possible to continuously remove digits from left to right, and remain prime at each stage: 3797, 797, 97, and 7. Similarly we can work…
Rubens Farias
  • 57,174
  • 8
  • 131
  • 162
0
votes
0 answers

Smarter way to truncate strings looks uniform in rails app?

Like monospace fonts(looks uniform), i have used below font-family font-family: "Helvetica Neue", Helvetica, Arial, sans-serif I don't want to change fonts, anyway to achieve same width for font using css?
EMR
  • 63
  • 4
0
votes
1 answer

Truncate decimals from column in SQL

How would I delete all the decimals from a column in SQL Server 2008? If I have a column X_Coord and had three rows with the value, how would I trim it so that there are NO decimals after the last whole number? For example, let's say my table is…
pistolpunz
  • 5
  • 2
  • 6
0
votes
2 answers

R File Name Truncate

We have a bunch of file names of the form: filename1(412)(4141567).csv, filename2(4214985).csv, filename3(34543).csv, filename4(3456984).csv, filename5(34582).csv, filename6(jrh)(234145).csv What we are looking to do is truncate the file names so…
user1836894
  • 293
  • 2
  • 5
  • 18
0
votes
1 answer

How to truncate end of SKU in Magento on frontend?

What I'm seeking to do is display the SKU of a product on the frontend of my Magento cart, which is working accurately with this code: htmlEscape($_product->getSku()) ?> However, what I need to do in addition to this is truncate…
Jennii
  • 3
  • 1
  • 3
0
votes
1 answer

Windows phone - C# - Truncating file(s) in IsolatedStorage

How can I remove 1 character off the end of a certain file in IsolatedStorage? The code I have so far is: var appStorage = IsolatedStorageFile.GetUserStoreForApplication(); using (var writer = new StreamWriter(appStorage.OpenFile("trailCount",…
Newbie
  • 1,160
  • 2
  • 11
  • 24
0
votes
2 answers

IE truncating URL?

I have a url (HTTP) that gets redirected. This is the end of the url with paramters: /c.html?ufl=c&rtr=on&s=x9w5pl,33gz,2cw,75vq,lelf,gwtv,jxou&RESNET_CODE=FIE&OFFERCODE=H38FR10 When I use chrome to GET this url, the original url gets redirected to…
richard
  • 12,263
  • 23
  • 95
  • 151