Minus date in string data type

Hi all,
i having one table in database that used to store the borrow_date and return_date, the date is in this format 06/12/2008, when i retrieve the date from the database, and i pass it into String data type, for example as follows:
private String borrow_date = 05/12/2008;
private String return_date = 10/12/2008;
if for example student A return the book on 15/12/2008, which is after the return_date in database, then i want to minus is 15/12/2008 with 10/12/2008, so that i can get the int value of 5 days. Because i want to use this integer 5 for late penalty. One day charge for 20 cent.
e.g: String borrow_date - String return_date = int total_days;
Now my problem is this, i dont know how to use string data type minus with string data type to get the integer type.
I had tried for many methods already, still cannot get it, i can get the total days in int data type if the date is in Date or Calendar data type. The problem now is the date is in String data type. Any idea from you? :)
Regards,
poh_cc

poh_cc wrote:
because in my case, i have to use string data type :)Thinking about this again, it really is stupid. You say you are even storing the dates in the database as Strings and not Dates. It can only lead to a world of hurt.

Similar Messages

  • Help with filtering a query with a date as string column

    Hello -- I've got a table column that contains dates as
    string/text type (access db). I need to make a query of my table
    that includes only the dates that match today's date (example
    5-13-2008). I need two parts. One is to capture today's date, and
    another to set the filter in the query.
    Here's my base query
    <cfquery name="someQuery" datasource="someDS">
    SELECT col1, col2, dateCol, col4
    FROM someTable
    WHERE dateCol = "today's date"
    </cfquery>
    What's the best way to capture today's date? And then what's
    the best way to set it to a string so I have an object to compare
    with dateCol. I know #now()# will get today's date, however it
    returns date + time. How can I format it as M-D-YYYY? Then, how do
    I convert it to a string so I can evaluate in my query? Any help is
    appreciated!

    quote:
    Originally posted by:
    Dan Bracuk
    Redesign your database and store dates as dates instead of
    strings.
    I would love to do this, however I couldn't figure out how to
    store date and time values AS DATE to my database. My front end is
    Flex with a Coldfusion backend. When a form is filled, I need it to
    send the current time and the current date of submission. Using
    Date(), I can obtain the current date (date + time). However it's
    not easy to separate the [date] and [time] values of the Date()
    result without using a dateformatter with a mask. By doing this,
    I've now taken my date as DATE and converted it to date and time
    both AS STRING. Well after several trial and error tries as well as
    looking for any help online, I just decided to use the
    dateformatter, convert date and time to string and then save each
    to their own columns.
    The other way of doing this is to just have one column that
    holds both the date and time, and use Date() to pass the correct
    data-type to my db. However, when passing Date() to my db, it only
    stores the date but sets the time to 00:00:00. Now if I could find
    a way to get both correct date and time (example 5-13-2008 1:31:xx
    PM), I could just use a dateformatter in my front end to display
    the dates as I want. Again, the problem is I need the TIME value as
    well, and it keeps defaulting to 00:00:00 in access.
    @paross1-- I will try what you've provided just to get this
    thing working, regardless if they are strings in the db instead of
    dates.
    If anyone can solve my default time issue mentioned above,
    that would be great too..

  • Convert string date

    Dear experts.
    How can I transfer a string date into string date of previous year, Ex: 24.10.2008  into => 24.10.2007
    Thanks for your reply
    Huynh Kim Binh

    Hi
    I got a solution, fomular is: DSTR(DADD(STORE@Date,-1,'Y'),"DD.MM.YYYY")
    Thanks
    HKBinh
    Edited by: Huynh Binh on Oct 25, 2008 5:17 AM

  • Dynamic structure of "string" data type. Please help.

    ABAPers,
    I am calling cl_alv_table_create=>create_dynamic_table method to dynamically create a structure. The input structure definition is as follows:
    data: xfc type lvc_s_fcat.
    data: ifc type lvc_t_fcat.
    * define Fld1
    clear xfc.
    xfc-fieldname = 'Fld1'.
    xfc-datatype = 'string'.
    append xfc to ifc.
    * define Fld2
    clear xfc.
    xfc-fieldname = 'Fld2'.
    xfc-datatype = 'string'.
    append xfc to ifc.
    Although the call to create_dynamic_table does not throw any exceptions, it appears Fld1 and Fld2 are not of "string" data type. I don't know of a way to see what type they are. However, they do have a length limit of 10 characters.
    After some experimenting, it turns out that the method simply ignores "datatype" value if it doesn't understand it and creates the field with some default data type.
    I would appreciate it if someone can show me how to create fields of "string" data type.
    Thank you in advance for your help.
    Pradeep

    That's right, use STRG as the datatype.  Please see the example program.
    report zrich_0003.
    type-pools: slis.
    data: new_table type ref to data,
          new_line  type ref to data.
    data:  xfc type lvc_s_fcat,
           ifc type lvc_t_fcat.
    field-symbols: <dyn_table> type standard table,
                   <dyn_wa>,
                   <fs>.
    start-of-selection.
      clear xfc.
      xfc-fieldname = 'Field1' .
      xfc-datatype = 'STRG'.
      append xfc to ifc .
      clear xfc.
      xfc-fieldname = 'Field2' .
      xfc-datatype = 'STRG'.
      append xfc to ifc .
    * Create dynamic internal table and assign to FS
      call method cl_alv_table_create=>create_dynamic_table
        exporting
          it_fieldcatalog = ifc
        importing
          ep_table        = new_table.
      assign new_table->* to <dyn_table>.
    * Create dynamic work area and assign to FS
      create data new_line like line of <dyn_table>.
      assign new_line->* to <dyn_wa>.
      assign component 1 of structure <dyn_wa> to <fs>.
      <fs> = 'This is string 1'.
      assign component 2 of structure <dyn_wa> to <fs>.
      <fs> = 'This is string 2'.
      append <dyn_wa> to <dyn_table>.
    * Write the values of internal table.
      loop at <dyn_table> into <dyn_wa>.
        do.
          assign component sy-index of structure <dyn_wa> to <fs>.
          if sy-subrc <> 0.
            exit.
          endif.
          write:/ <fs>.
        enddo.
      endloop.
    REgards,
    Rich Heilman

  • About string data type

    Hi
    Maximum number of characters that a string data type accepts in Java.
    Thanks..

    The next may give a rough test.
    public static void main(String[] args) throws Exception{
    int factor= Integer.parseInt(args[0]);
    char[] data = new char[Integer.MAX_VALUE/factor];// note: integer division
    for(int k=0;k<data.length;k++)  data[k]=(char)0x30;
    String s=new String(data);
    System.out.println(Integer.toString(s.length()));
    }

  • Re: String data type

    the string scalar type doesn't have that functionality, but if you use a
    TextData it has the methods you are looking for.
    Anthony N wrote:
    >
    Hi
    Is there a built-in function/method to perform substring on an input
    string?
    If there is no such method, what is the quick and easy way to do
    substring on a string?
    Thanks
    Anthony
    Do You Yahoo!?
    Get your free @yahoo.com address at http://mail.yahoo.com
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>--
    Paul Monax
    Senior Consultant
    Sage IT Partners
    303.779.3309 x204
    [email protected]
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    There is a Std FM RFC_GET_TABLE_ENTRIES available to read the entries using the RFC destination. This FM returns the output in the flat structure. You need to transform this flat structure to your specific structure.
    You mentioned:
    PS: I know I could transform each DB field into a String, transfer it via RFC, and then re-transform this String back into the original data type. However, I would like to avoid this data transformation if possible.
    What are the reasons you want to avoid this?
    Regards,
    Naimesh Patel

  • Building a table with a string data type

    I am using the Build Table function and I would like to be able to label my columns on the first iteration with a string data type, which doesn't seem to be an acceptable signal for the Build Table function. However, the express table is located under "text indicators" on the front panel, so it seems like there should be a way to do this..

    Ah, the "Build Table" Express VI. I hate Express VIs.
    That Express VI is nothing more than a really complicated way of creating a 2D array of strings. The Express VI has no inputs for the row and column headers, so you need to add them in yourself. The same would be true for a regular table control/indicator. Here's what you need to do:
    Right-click on the table indicator and select Visible Items -> Column Headers.
    Right-click on the table indicator and select Create -> Property Node -> Column Header Strings[]. LabVIEW will attach a property node to the cursor and switch to the block diagram. Plop down the property node on the block diagram.
    Right-click on the property node on the block diagram and select "Change All to Write".
    Right-click on the property node and select "Create -> Constant". This will give you an array of strings, and you can enter the column headers in each array element.
    Wire the array to the property node.
    Connect the property node to the Build Table Express VI using the error clusters.
    Message Edited by smercurio_fc on 07-02-2008 09:25 AM
    Attachments:
    Example_VI_BD6.png ‏3 KB

  • SSIS Package : While Extracting Sharepoint Lookup column, getting error 'Cannnot convert between unicode and non-unicode string data types'

    Hello,
    I am working on one project and there is need to extract Sharepoint list data and import them to SQL Server table. I have few lookup columns in the list.
    Steps in my Data Flow :
    Sharepoint List Source
    Derived Column
    its formula : SUBSTRING([BusinessUnit],FINDSTRING([BusinessUnit],"#",1)+1,LEN([BusinessUnit])-FINDSTRING([BusinessUnit],"#",1))
    Data Conversion
    OLE DB Destination
    But I am getting the error of not converting between unicode and non-unicode string data types.
    I am not sure what I am missing here.
    In Data Conversion, what should be the Data Type for the Look up column?
    Please suggest here.
    Thank you,
    Mittal.

    You have a data conversion transformation.  Now, in the destination are you assigning the results of the derived column transformation or the data conversion transformation.  To avoid this error you need use the data conversion output.
    You can eliminate the need for the data conversion with the following in the derived column (creating a new column):
    (DT_STR,100,1252)(SUBSTRING([BusinessUnit],FINDSTRING([BusinessUnit],"#",1)+1,LEN([BusinessUnit])-FINDSTRING([BusinessUnit],"#",1)))
    The 100 is the length and 1252 is the code page (I almost always use 1252) for interpreting the string.
    Russel Loski, MCT, MCSE Data Platform/Business Intelligence. Twitter: @sqlmovers; blog: www.sqlmovers.com

  • Column "A" cannot convert between unicode and non-unicode string data types

    I am following the SSIS overview video-
    https://secure.cbtnuggets.com/it-training-videos/series/microsoft-sql-server-2008-business-development/6143?autostart=true
    I have a flat file that i want to import the contents onto a SQL database.
    I created a Dataflow task, source file and oledb destination.
    I am getting the folliwung error -
    "column "A" cannot convert between unicode and non-unicode string data types"
    in the origin file the data type is coming as string[DT_STR] and in the destination object it is coming as "Unicode string [DT_WSTR]"
    I used a data conversion object in between, dosent works very well
    Please help what to do

    I see this often.
    Right Click on FlatFileSource --> Show Advanced Editor --> 'Input and Output Properties' tab --> Expand 'Flat File Source Output' --> Expand 'Output Columns' --> Select your field and set the datatype to DT_WSTR.
    Let me know if you still have issues.
    Thank You,
    Jay

  • Cannot convert between unicode and non-unicode string data types.

    I'm trying to copy the data from 21 tables in a SQL 2005 database to a MS Access database using SSIS. Before converting the SQL database from 2000 to 2005 we had this process set up as a DTS package that ran every month for years with no problem.  The only way I can get it to work now is to delete all of the tables from the Access DB and have SSIS create new tables each time. But when I try to create an SSIS package using the SSIS Import and Export Wizard to copy the SQL 2005 data to the same tables that SSIS itself created in Access I get the "cannot convert between unicode and non-unicode string data types" error message. The first few columns I hit this problem on were created by SSIS as the Memo datatype in Access and when I changed them to Text in Access they started to work. The column I'm stuck on now is defined as Text in the SQL 2005 DB and in Access, but it still gives me the "cannot convert" error.

    I was getting same error while tranfering data from SQL 2005 to Excel , but using following method i was able to tranfer data. Hopefully it may also help you.
    1) Using Data Conversion transformation
       data types you need to select is DT_WSTR (unicode in terms of SQL: 2005)
    2) derived coloumn transformation
       expression you need to use is :
        (DT_WSTR, 20) (note : 20 can be replace by your character size)
    Note:
    Above teo method create replica of your esting coloumn (default name will be copy of <coloumn name>).
    while mapping data do not map actual coloumn to the destination but select the coloumn that were created by any of above data transformer (replicated coloumn).

  • How to fix "cannot convert between unicode and non-unicode string data types" :/

    Environment: SQL Server 2008 R2
    Introduction:Staging_table is a table where data is being stored from source file. Individual and ind_subject_scores are destination tables.
    Purpose: To load the data from a source file .csv while SSIS define table  fields with 50 varchar, I can still transfer the data to the entity table/ destination and keeping the table definition.
    I'm getting validation error "Cannot convert between a unicode and a non-unicode string data types" for all the columns.
    Please help

    Hi ,
    NVARCHAR = DT_WSTR
    VARCHAR = DT_STR
    Try below links:
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/ed1caf36-7a62-44c8-9b67-127cb4a7b747/error-on-package-can-not-convert-from-unicode-to-non-unicode-string-type?forum=sqlintegrationservices
    http://social.msdn.microsoft.com/Forums/en-US/eb0d1519-4be3-427d-bd30-ae4004ea9e8d/data-conversion-error-how-to-fix-this
    http://technet.microsoft.com/en-us/library/aa337316(v=sql.105).aspx
    http://social.technet.microsoft.com/wiki/contents/articles/19612.ssis-import-excel-to-table-cannot-convert-between-unicode-and-non-unicode-string-data-types.aspx
    sathya - www.allaboutmssql.com ** Mark as answered if my post solved your problem and Vote as helpful if my post was useful **.

  • Unicode and non-unicode string data types Issue with 2008 SSIS Package

    Hi All,
    I am converting a 2005 SSIS Package to 2008. I have a task which has SQL Server as the source and Oracle as the destination. I copy the data from a SQL server view with a field nvarchar(10) to a field of a oracle table varchar(10). The package executes fine
    on my local when i use the data transformation task to convert to DT_STR. But when I deploy the dtsx file on the server and try to run from an SQL Job Agent it gives me the unicode and non-unicode string data types error for the field. I have checked the registry
    settings and its the same in my local and the server. Tried both the data conversion task and Derived Column task but with no luck. Pls suggest me what changes are required in my package to run it from the SQL Agent Job.
    Thanks.

    What is Unicode and non Unicode data formats
    Unicode : 
    A Unicode character takes more bytes to store the data in the database. As we all know, many global industries wants to increase their business worldwide and grow at the same time, they would want to widen their business by providing
    services to the customers worldwide by supporting different languages like Chinese, Japanese, Korean and Arabic. Many websites these days are supporting international languages to do their business and to attract more and more customers and that makes life
    easier for both the parties.
    To store the customer data into the database the database must support a mechanism to store the international characters, storing these characters is not easy, and many database vendors have to revised their strategies and come
    up with new mechanisms to support or to store these international characters in the database. Some of the big vendors like Oracle, Microsoft, IBM and other database vendors started providing the international character support so that the data can be stored
    and retrieved accordingly to avoid any hiccups while doing business with the international customers.
    The difference in storing character data between Unicode and non-Unicode depends on whether non-Unicode data is stored by using double-byte character sets. All non-East Asian languages and the Thai language store non-Unicode characters
    in single bytes. Therefore, storing these languages as Unicode uses two times the space that is used specifying a non-Unicode code page. On the other hand, the non-Unicode code pages of many other Asian languages specify character storage in double-byte character
    sets (DBCS). Therefore, for these languages, there is almost no difference in storage between non-Unicode and Unicode.
    Encoding Formats: 
    Some of the common encoding formats for Unicode are UCS-2, UTF-8, UTF-16, UTF-32 have been made available by database vendors to their customers. For SQL Server 7.0 and higher versions Microsoft uses the encoding format UCS-2 to store the UTF-8 data. Under
    this mechanism, all Unicode characters are stored by using 2 bytes.
    Unicode data can be encoded in many different ways. UCS-2 and UTF-8 are two common ways to store bit patterns that represent Unicode characters. Microsoft Windows NT, SQL Server, Java, COM, and the SQL Server ODBC driver and OLEDB
    provider all internally represent Unicode data as UCS-2.
    The options for using SQL Server 7.0 or SQL Server 2000 as a backend server for an application that sends and receives Unicode data that is encoded as UTF-8 include:
    For example, if your business is using a website supporting ASP pages, then this is what happens:
    If your application uses Active Server Pages (ASP) and you are using Internet Information Server (IIS) 5.0 and Microsoft Windows 2000, you can add "<% Session.Codepage=65001 %>" to your server-side ASP script.
    This instructs IIS to convert all dynamically generated strings (example: Response.Write) from UCS-2 to UTF-8 automatically before sending them to the client.
    If you do not want to enable sessions, you can alternatively use the server-side directive "<%@ CodePage=65001 %>".
    Any UTF-8 data sent from the client to the server via GET or POST is also converted to UCS-2 automatically. The Session.Codepage property is the recommended method to handle UTF-8 data within a web application. This Codepage
    setting is not available on IIS 4.0 and Windows NT 4.0.
    Sorting and other operations :
    The effect of Unicode data on performance is complicated by a variety of factors that include the following:
    1. The difference between Unicode sorting rules and non-Unicode sorting rules 
    2. The difference between sorting double-byte and single-byte characters 
    3. Code page conversion between client and server
    Performing operations like >, <, ORDER BY are resource intensive and will be difficult to get correct results if the codepage conversion between client and server is not available.
    Sorting lots of Unicode data can be slower than non-Unicode data, because the data is stored in double bytes. On the other hand, sorting Asian characters in Unicode is faster than sorting Asian DBCS data in a specific code page,
    because DBCS data is actually a mixture of single-byte and double-byte widths, while Unicode characters are fixed-width.
    Non-Unicode :
    Non Unicode is exactly opposite to Unicode. Using non Unicode it is easy to store languages like ‘English’ but not other Asian languages that need more bits to store correctly otherwise truncation will occur.
    Now, let’s see some of the advantages of not storing the data in Unicode format:
    1. It takes less space to store the data in the database hence we will save lot of hard disk space. 
    2. Moving of database files from one server to other takes less time. 
    3. Backup and restore of the database makes huge impact and it is good for DBA’s that it takes less time
    Non-Unicode vs. Unicode Data Types: Comparison Chart
    The primary difference between unicode and non-Unicode data types is the ability of Unicode to easily handle the storage of foreign language characters which also requires more storage space.
    Non-Unicode
    Unicode
    (char, varchar, text)
    (nchar, nvarchar, ntext)
    Stores data in fixed or variable length
    Same as non-Unicode
    char: data is padded with blanks to fill the field size. For example, if a char(10) field contains 5 characters the system will pad it with 5 blanks
    nchar: same as char
    varchar: stores actual value and does not pad with blanks
    nvarchar: same as varchar
    requires 1 byte of storage
    requires 2 bytes of storage
    char and varchar: can store up to 8000 characters
    nchar and nvarchar: can store up to 4000 characters
    Best suited for US English: "One problem with data types that use 1 byte to encode each character is that the data type can only represent 256 different characters. This forces multiple
    encoding specifications (or code pages) for different alphabets such as European alphabets, which are relatively small. It is also impossible to handle systems such as the Japanese Kanji or Korean Hangul alphabets that have thousands of characters."<sup>1</sup>
    Best suited for systems that need to support at least one foreign language: "The Unicode specification defines a single encoding scheme for most characters widely used in businesses around the world.
    All computers consistently translate the bit patterns in Unicode data into characters using the single Unicode specification. This ensures that the same bit pattern is always converted to the same character on all computers. Data can be freely transferred
    from one database or computer to another without concern that the receiving system will translate the bit patterns into characters incorrectly.
    https://irfansworld.wordpress.com/2011/01/25/what-is-unicode-and-non-unicode-data-formats/
    Thanks Shiven:) If Answer is Helpful, Please Vote

  • Metadata Field -- List of Strings -- Data Type

    I'm trying to create a dropdown List to create a custom Metadata . i saw that the data type "list of strings" is available on already created metadata , but once i try to create a custom metadata list I can find the List of Strings datatype . did i missed something when i installed FCS?
    is this possible.
    I wish i could add a keyword dropdown list, as we can do with booleans but of course with more than 2 choices.

    Sorry, since the french translation of the manual is not crystal clear, i didn't know i had to use the lookup feature. i jsut bought Getting Started with Final Cut Server (Matthew Geller - PeachPress ed.) where i got the final answer.
    anyway, it's not very handy because it would be easier to unlock the List of Strings darta type to create a new metadata field.
    i'm a newbie sorry again.

  • What is the size of a string data type

    Hello,
    What is the size of a string data type. Also what is the maximum size upto which a text file can grow?
    Thanks in advance
    cooldude 

    Hi cooldude,
    the size of a string is given back by the function "String size". Strings are dynamically managed in LabView.
    The max filesize is limited by the used filesystem. FAT-based systems are limited to 4GB (or was it 2GB?), other filesystems may allow more...
    Best regards,
    GerdW
    CLAD, using 2009SP1 + LV2011SP1 + LV2014SP1 on WinXP+Win7+cRIO
    Kudos are welcome

  • Flatten Variant to String vs. Flatten Data to String in case of variant data type

    May be a dumb question, but I want just understand what is the principal difference and what are the restrictions for both methods? Also I noticed that in case of "Flatten Variant to String" it looses all its attibutes, and this is not in case of flatten generic data to sting. Where I can find a more detailed info on this?
    LabView Ver. 6.0,6.1

    defuflo,
    See OpenG.org >> Site Docs >> LabVIEW Data 1 of 2.
    On non variant data, "Flatten to String" and "Variant to Flattened String" have the same output.
    On Variant data, "Variant to Flattened String" ouputs the flattened string and type string of the sub-type held in the variant. All variant attributes are lost in the process since they belong to the variant, not to the subtype.
    "Flatten to String" operates on variants like on any other types, returning the type string of a variant and all its flattened data, including any attributes.
    LabVIEW, C'est LabVIEW

Maybe you are looking for

  • My Infinity experience so far......

    Hi all Well I thought I would post a message with my experience so far after returning to BT for internet service. I should first mention I have an extremely low opinion of BT because ever since I first started dealing with them back in 2001 I have h

  • C# winform + crystalreportviewer to export HTML format  ?

    Hi,guys.   I create a winform app with a crystalreportViewer[cr dev for vs 2012], and i found CR can export many formats,like pdf,word,excel.   But I can't find "HTML" format. Although I know we can export HTML in the editor environment's preview mod

  • Blu-Ray Problem of Menu

         First I want to apologize for my English.      I do a project in Encore CS5 (5.0.0.508) of 4.7 or a DVD 8.5 GB PAL 720x576 5 stars it works in any DVD player. I do blu-ray PAL 1280x720 movie of the same menu of the Display is green and does not

  • RAZERBACK MOUSE COMPATIBLE WITH MAC???

    any info on this subject would be nice. i want to get one for my macbook. TY.

  • How to setup rotation for application.log?

    In order to get the Portal Performance Statistics running, we need to retrieve the page views from file application.log in directory <ORAHOME>\j2ee\OC4J_Portal\application-deployments\portal\OC4J_Portal_default_island_1. This file continues to grow a