Date function

I read man page for etc/shadow field..

on the 8th field, i assume that's the field to change account expire date.

my question is:

What value does the 8th field keep? i assume it's 13514 instead of "Date" value such as 11/10/08.

on the man page, it said: " expire value = 13514 = jan 1, 2007"

How do you get 13514 ?

Is there any calculation involves?

It did not say that. If it did it is wrong.

That field is the number of days AFTER Jan 1, 1970 that the account expires - becomes unusable.

ok..

but how do i convert the date format (10/10/08) to unix format to be used at 8th field?

Read the faq article on date arithmetic. It has a link to my datecalc script.

$ ./datecalc -a 2007 1 1 - 1970 1 1
13514
$

You should read man date for your *NIX, this solution should work on Linux date (GNU coreutils) 5.97

dt=1/1/07                   # For January 1, 2007
# dt=$(date "+%d/%m%y")     # For current date
var=$(($(date -d $dt "+%s") / 86400))
echo $var
13514

i made some syntax modification which are:

#old=1/1/07
old=`date +%d%m%y`
var="(`(date -u $old "+%s")`/ 86400)"
echo $var

but i have a problme with the third line..

when i read man page for date, it only supports

usage: date [-u] mmddHHMM[[cc]yy][.SS]
date [-u] [+format]
date -a [-]sss[.fff]

i'm guessing i should use -u but i think it's wrong

What OS? and where you perform the calculation?

o/s : sun solaris
I try to perform the calculation within script

Do i need to use expr expression to perform the division ?

Why don't you use the datecalc script of Perderabo? Copy and paste the script in your directory, make it executable and call it in your script as follow:

datediff=`./datecalc -a 2007 1 1 - 1970 1 1`
echo "$datediff"

Regards


it'sbecasue i have syntax problem

some of the command swith can;t run on sun solaris

I use it on Solaris all the time.

ok..

oopss.. sorry

it works now

i missing out couple of stuff when i did copy and paste

it's ok now

thanks