zoukankan      html  css  js  c++  java
  • 一些容易忽略的小点

    开发过程中碰到的一些小点,记忆一下:
    SQL SERVER:
    若是空,则选择某个默认值:
    isnull(a,'b')
    字符串转换成整数:
    cast(a as int)
    定位某个字符的位置:
    charindex('.',a,1)
    截取某个子串:
    substring(a,start_index,length)
    如取1.02.03.04处的02
    select substring('1.02,03.04',charindex('.','1.02.03.04',1)+1,charindex('.','1.02.03.04',charindex('.','1.02.03.04',1)+1)-charindex('.','1.02.03.04',1)-1)
    日期转换成普通字符串格式:
    select convert(varchar(10),getdate(),23)
    字符串转换成日期:
    select cast('2009-02-01' as datetime)

    ORACLE:
    若是空,则选择某个默认值:
    nvl(a,'b')
    字符串转换成整数:
    select to_number('5') from dual
    定位某个字符的位置:
    INSTR(C1,C2,I,J)
    在一个字符串中搜索指定的字符,返回发现指定的字符的位置;
    C1 被搜索的字符串
    C2 希望搜索的字符串
    I 搜索的开始位置,默认为1
    J 出现的位置,默认为1
    SQL> select instr(oracle traning,ra,1,2) instring from dual;
    INSTRING
    ---------
    9
    截取某个子串:
    SUBSTR(string,start,count)
    取子字符串,从start开始,取count个,start从1开始计数
    SQL> select substr(13088888888,3,8) from dual;
    SUBSTR(
    --------
    08888888
    日期转换成普通字符串格式:
    to_char(sysdate,'yyyy-mm-dd')
    字符串转换成日期
    to_date('2009-01-02','yyyy-mm-dd')

    C#:
    保留两位小数:
    a.ToString("00")
    四舍六入五取偶
    _基薪现金 = Math.Round(_基薪现金, 2, MidpointRounding.AwayFromZero);
    asp.net显示时,取两位小数:
    <asp:BoundField DataField="基本工资" HeaderText="基本工资" DataFormatString="{0:N}" HtmlEncode="False"  ItemStyle-HorizontalAlign=Right>

  • 相关阅读:
    mac使用ssh出现permission denied(publickey)
    mac下解压bin文件
    Lint found fatal errors while assembling a release target问题的解决方案
    Cloud Foundry 组件
    maven中的groupId和artifactId到底指的是什么
    SpringBoot之常用注解
    Kafka系列文章
    [转]Kafka 设计与原理详解
    十张图了解Docker【转】
    四层、七层负载均衡的区别
  • 原文地址:https://www.cnblogs.com/tianfu/p/1487142.html
Copyright © 2011-2022 走看看