在 AIX UNIX 中将字符串值转换为常规日期 [英] convert a string value into regular date in AIX UNIX

查看:18
本文介绍了在 AIX UNIX 中将字符串值转换为常规日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的 UNX 脚本中传递一个 Julian 日期值作为参数.根据日期值,它被转换为常规日期.但是,限制是目前我只能将其转换为当前或上一个日期.以下是我的代码

I am passing a Julian date value as argument in my UNX script. Based on the date value it gets converted to regular date. However the constraint is that currently I am able to convert it only for current or previous date. following is my code

    PARAM_NAME=$1
PARAM_VALUE=$2 //where Julian date is passed

if [[  $PARAM_NAME == 'LOANS_BATCH_CONTROL_PS.ISLFILE_PROCESSING_DATE' && $PARAM_VALUE == `TZ=aaa24 date +%y%j` ]]; then
date_replace_string=`TZ=aaa24 date +%m%d%Y`
PARAM_VALUE=$date_replace_string

我想知道是否可以将这个 paramter_value 与任何日期值(儒略日期:例如 16074)一起转换为常规日期,而不仅仅是当天日期或前一天日期

I wondered if there is anyway where I could take this paramter_value with any date value(julian date: eg. 16074) and convert it to a regular date and not just current day date or previous day date

推荐答案

Dateutils 可以做到:

$ dateconv -i '%y%D' 16074 -f '%Y-%m-%d'
2016-03-14

其中 %D 是一年中的天数.

where %D is the day-of-year count.

免责声明:我是该工具的作者.

Disclaimer: I am the author of the tool(s).

这篇关于在 AIX UNIX 中将字符串值转换为常规日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆