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

Truncating multiline texts with links ( tags) in truncated part with css

I have a div which gets populated dynamically with some text that may or may not contain a link(s). For eg:
Welcome to Stackoverflow. Someone will provide an answer to this question. Just sit back and relax, or go check your
ScorpionKing2k5
  • 2,491
  • 1
  • 18
  • 18
0
votes
3 answers

How can I dynamically pass the result of TRUNC_TIMESTAMP of any kind in my JCL steps?

I am looking to create a JCL stream that will do the following: Step 1: Run a instream DB2 Param1 = SELECT TRUNC_TIMESTAMP(CURRENT TIMESTAMP,'MONTH') FROM SYSIBM.SYSDUMMY1;` Step 2: Param2 = SELECT TRUNC_TIMESTAMP(CURRENT TIMESTAMP +…
0
votes
1 answer

Find and truncate a link from a text in Rails

I'm looking for a way to truncate links displayed in my text. Ie:

Into :

I want to share a link :…

Fabien
  • 273
  • 5
  • 12
0
votes
0 answers

sql server uniqueidentitifer "newid()" truncates the characters "3D" when emailed out

I looked through a lot of the questions but I can't seem to find anything related to this. I basically have a bunch of invoices which is represented by invoice hashes: 36 character hex with dashes, i.e. (notice the 3D in the 2nd…
w1ck3d64
  • 402
  • 2
  • 8
  • 15
0
votes
4 answers

What is the equivalent effect to Truncating a table, when the table is referenced by a foreign-key

Straight out of the MSDN docs for Sql Server 2005: You cannot use TRUNCATE TABLE on tables that: Are referenced by a FOREIGN KEY constraint. Participate in an indexed view. Are published by using transactional replication or merge replication. I…
Ophidian
  • 9,775
  • 2
  • 29
  • 27
0
votes
1 answer

Separating Part of a String in Excel

I have a column of data that is alpha-numeric and has multiple "." separator between various numbers, what I am looking to do is pull the last five characters of this string and move it to a separate column. Is there a feature(or combination of…
0
votes
1 answer

Twig incorrect truncated html

I save news text in DB as HTML:

Hello, i'm a text!

More text

When i render text like this {{ post.body | raw }} everything goes well, but i need to truncate text to 20-30 symbols for preview on main page. So, i tried {{ p.body[:20] ~…
Eugene
  • 85
  • 2
  • 5
0
votes
2 answers

How to re-insert records from temporary table after truncate and keep ID column values

Let's say I want to delete all records in a SQL Server table that were inserted over three months ago and keep the records inserted since then. We're dealing with many records on both sides of the three month period so I decided instead of running a…
James Cahours
  • 85
  • 2
  • 8
0
votes
4 answers

python if a list is over 20 characters shorten it to 20 if it is less than 20 characters, add 0s to make it 20

in a python program, I have ... wf = raw_input("enter string \n") wl = list(wf) wd = wl[:-4] #now I want to see if wl is over 20 characters #if it is, I want it truncated to 20 characters #if not, I want character appended until it is 20…
pokeswap
  • 15
  • 3
0
votes
1 answer

full calendar truncate title

I am using fullcalendar 1.6.0, with qtip2, building an array in php and using this as the events list $('#calendar').fullCalendar({ // put your options and callbacks here events: [ ], It is working fine,…
Craig Rushforth
  • 233
  • 4
  • 13
0
votes
2 answers

Inserting dynamic pivot result into an existing table without knowing table definition

I have a dynamic pivot table that produces an unknown number of columns until runtime. I am trying to clear the data out of an existing table and insert the results of my query into it. The problem that I am having is that I do not know what the…
Roland P
  • 393
  • 1
  • 9
  • 27
0
votes
1 answer

php file_put_contents truncates string after whitespace

file_put_contents seems to truncate my string variable. HTML
JavaScript function submitData() { var string = $('textarea[name=string]').val(); …
JustSomeGuy
  • 315
  • 2
  • 17
0
votes
4 answers

Truncate floor into three decimal point C++

I want to truncate floor number to be 3 digit decimal number. Example: input : x = 0.363954; output: 0.364 i used double myCeil(float v, int p) { return int(v * pow(float(10),p))/pow(float(10),p ); } but the output was 0.3630001 . I tried to…
Fadwa
  • 1,717
  • 5
  • 26
  • 43
0
votes
3 answers

Truncation error in taking square root in python

I'm trying to use Fermat's factorization method http://en.wikipedia.org/wiki/Fermat%27s_factorization_method to factor a RSA exercise with n = pq =…
user3100957
0
votes
2 answers

Reusable jQuery truncate function

So I have created the following code to deal with one instance of a string that requires truncating with expandable and collapsable click events. $(document).ready(function () { var Element = $("[class*='truncate']"); var FullText =…
Rich
  • 33
  • 7