Search code examples
unixtimestampdb2cut

how to cut timestamp using Cut command upto a particular point?


I fetched timestamp sysibm.sysdummy. If the timestamp is 2015-08-21.23.35.45.45287 ,I need to cut it till the minutes only i.e. 2015-08-21.23.35. Can any one tell me how to cut this using unix commands?


Solution

  • When you want to cut it, use

    echo '2015-08-21.23.35.45.45287' | cut -d"." -f1-3
    

    Cut might not be the best solution, consider the DB2 expression (@data_henrik) or the shell built-in

    a="2015-08-21.23.35.45.45287"; echo ${a:0:16}