Click to See Complete Forum and Search --> : date conversion


Ewa3sherif
07-26-2001, 11:45 AM
Hello,

Is it possible to convert a date (day) string to an integer in a shell script? I work with KSH... and I have to obtain the day in numeric format.

For ex: the first of january 2001 is the number "1" etc

...and if this convertion isn't possible, could I find with a date string the number of a day's week ?

for ex: monday is the first day of the week...

Could someone help-me please. :confused:

7DeadlySins
07-27-2001, 06:10 AM
well, if you catch the output of

date +%j

you get an integer value representing the day of year, and

date +%w

gives you an integer value of the day of the week, so something as simple as

DATE = `date +%j`

would capture the information.
Does this satisfy your needs?

7DS