---------- Post updated at 03:42 AM ---------- Previous update was at 03:38 AM ----------
Sorry for a duplicate post, my post at the first place could not appear due to some net issue on my machine. Here is what i posted earlier:
Hi, i am using ksh in Solaris, i wanted to assign today's, yesterday's, and day before yesterday's date ( in mm/dd/YYYY format) to a variable in a script. Presently i am using :
It works fine most of the time until today's date is 1 . Going by above logic, last two day's date would be 0 and -1, which in turn should be 30 and 29 or 31 and 30 based on the month( and a special case for February and leap year ). Presently i am making an exception on those days and making my job manually, but i wish to automate the process all along. Can someone help me to have a more optimized and accurate logic.
Thanks in advance
hi,
Problem is similar so tried continuing in the same thread than opening a new one. the problem now is i am trying to calculate time elapsed between two instances, at present i am using below in awk where date command doesn't work:
my input file will be like
name1 12/16/2013 10:56:38 12/16/2013 10:59:37 value1
name2 12/16/2013 04:37:41 12/17/2013 11:34:19 value2
and so on(a sequence of such records)
the problem again is the same. If start of the month appears with date 01 the previous day would be 31 or 30 or 28 (or 29 ) and my logic above wont work then.
One way is i hard code such inatances with month values in case statement. But just want to know if there is some better option to deal this ?
Any help will be gratefully welcome :-)
---------- Post updated 12-18-13 at 01:34 PM ---------- Previous update was 12-17-13 at 05:40 PM ----------
Does any one have any update? Atleast someone reply that there is no other way to do. Please make a reply so that I try some approach of mine.
Last edited by pr5439; 12-17-2013 at 06:57 PM..
Reason: more explaination
Location: Saint Paul, MN USA / BSD, CentOS, Debian, OS X, Solaris
Posts: 2,288
Thanks Given: 430
Thanked 480 Times in 395 Posts
Hi.
A group of date-manipulation utilities is available, among them ddiff. Here's how it works with your sample data:
producing:
This was run under ksh (some demo-support scripts use bash).
See the git web page noted in the script. One would need to download and compile the codes (written in c) as I have done today in Solaris:
if this is beyond your skills then use other solutions above.
Gents.
Please can u help.
I would like to calculate the days between two dates.
Example file1 ( previous date)
file1 - Input file
9/29/2010 10195
9/29/2010 1057
2/2/2016 10
2/2/2016 10169
2/2/2016 1057
2/3/2016 10005
2/3/2016 10014
In file2 I add the actual date using this code.... (9 Replies)
Hi Guys,
Need a small help, how do i get the difference between two dates (in days) in KSH shell
My date is in mm/dd/YYYY format,
Is there a function to get time stamp from the respective date and time ( mm/dd/yyyy HH:MM:SS) (1 Reply)
I have two times in the format of YYMMDD. Does anyone know an easy way in ksh for me to display how many days are between the two dates?
Example1:
X=101202
Y=101205
There are 3 days between X & Y
Example2:
X=101202
Y=111202
There are 365 days between X & Y
Example3:
X=101205... (3 Replies)
i need help! can someone help me please?
i try to calculate date under unix (ksh)...AIX operating system.
I have to find the date 200 days from today's date.
then the script should loop 200 times and display on command line every day's date until the current date.
example:
todays date:... (4 Replies)
i need help! can someone help me please?
i try to calculate date under unix (ksh)...AIX operating system.
I have to find the date 200 days from today's date.
then the script should loop 200 times and display on command line every day's date until the current date.
example:
todays date:... (1 Reply)
I am familiar with using the 'date' command to get the current date but I have a situation where I need to get the previous day's date as well as the date two days prior. Theoretically I could use 'expr' to compute these values but I need it to work in instances where the previous month's dates... (2 Replies)
Hello,
I would like to find out the number of days between two dates of the format yyyy-mm-dd.
Any help on this is highly appreciated.
Thanks. (6 Replies)
Is there any way to use date with previous dates such as "2 23 2000" in order to see what day of the week it was? I tried changing the current date to "date 022300452000"
but then it told me that I could not do this because I was "Not the owner". Any other ways of getting the day result? (2 Replies)
Hi All
How to get the difference between two dates in no of days ??? My date format is like this YYYY/MM/DD. I have to get the no of days between two dates in the given format.
I tried to search the forum but nothing came up similar to my requitement. Your help will be appreciated.
... (1 Reply)
does anybody know how to find out the number of
days elapsed between 2 dates
e.g.
days elapsed between 020212 and 020110 (YYMMDD format)
Thanking you in advance.
Ravi. (1 Reply)