Convert DATE to NUMBER

  • Follow


Hi all,

	I am trying to find the days between two dates.  I thought about
converting the dates to Julian but I don't think that is the direction
I should be going for.

I'd really like to convert the dates to a date number i.e.;

01/01/2007 - DAY OF YEAR = 1
01/31/2007 - DAY OF YEAR = 31
10/01/2007 - DAY OF YEAR = 274
12/31/2007 - DAY OF YEAR = 365

or is there a better way to find the days between two dates?

I am running both Windows 98 and Windows XP OS's using GAWK 2.15
patchlevel 6


Thanks for any help

sKurt
-- 

0
Reply sKurt 10/1/2007 5:18:57 AM

On 1 Okt., 07:18, "sKurt" <sk...@remove.inbox.com> wrote:
> Hi all,
>
>         I am trying to find the days between two dates.  I thought about
> converting the dates to Julian but I don't think that is the direction
> I should be going for.
>
> I'd really like to convert the dates to a date number i.e.;
>
> 01/01/2007 - DAY OF YEAR = 1
> 01/31/2007 - DAY OF YEAR = 31
> 10/01/2007 - DAY OF YEAR = 274
> 12/31/2007 - DAY OF YEAR = 365

$ gawk 'BEGIN{print strftime("%j",mktime("2007 10 01 00 00 00"))}'
274

To create the mktime() date string from the above format use split().

Janis

>
> or is there a better way to find the days between two dates?
>
> I am running both Windows 98 and Windows XP OS's using GAWK 2.15
> patchlevel 6
>
> Thanks for any help
>
> sKurt
> --


0
Reply Janis 10/1/2007 7:47:21 AM


Janis wrote:


> > 
> > I'd really like to convert the dates to a date number i.e.;
> > 
> > 01/01/2007 - DAY OF YEAR = 1
> > 01/31/2007 - DAY OF YEAR = 31
> > 10/01/2007 - DAY OF YEAR = 274
> > 12/31/2007 - DAY OF YEAR = 365
> 
> $ gawk 'BEGIN{print strftime("%j",mktime("2007 10 01 00 00 00"))}'
> 274
> 
> To create the mktime() date string from the above format use split().
> 
> Janis
> 
> > 
> > or is there a better way to find the days between two dates?
> > 
> > I am running both Windows 98 and Windows XP OS's using GAWK 2.15
> > patchlevel 6
> > 
> > Thanks for any help
> > 
> > sKurt

Thanks Janis, I will give this a try.  I already have the two dates
that I need to compare as variables, I will examine the code to see
what I can make of it.

sKurt



-- 

0
Reply sKurt 10/1/2007 2:06:41 PM

Janis wrote:


> > 
> > I'd really like to convert the dates to a date number i.e.;
> > 
> > 01/01/2007 - DAY OF YEAR = 1
> > 01/31/2007 - DAY OF YEAR = 31
> > 10/01/2007 - DAY OF YEAR = 274
> > 12/31/2007 - DAY OF YEAR = 365
> 
> $ gawk 'BEGIN{print strftime("%j",mktime("2007 10 01 00 00 00"))}'
> 274
> 
> To create the mktime() date string from the above format use split().
> 
> Janis

> > Thanks for any help
> > 
> > sKurt

Sorry, in a DOS/WINDOWS world here, where do I get split()  That is a
Gawk command?  Sorry, I haven't checked just yet.

Thanks again

sKurt



-- 

0
Reply sKurt 10/1/2007 2:11:19 PM

On 1 Okt., 16:11, "sKurt" <sK...@REMOVE.inbox.com> wrote:
> Janis wrote:
>
> > > I'd really like to convert the dates to a date number i.e.;
>
> > > 01/01/2007 - DAY OF YEAR = 1
> > > 01/31/2007 - DAY OF YEAR = 31
> > > 10/01/2007 - DAY OF YEAR = 274
> > > 12/31/2007 - DAY OF YEAR = 365
>
> > $ gawk 'BEGIN{print strftime("%j",mktime("2007 10 01 00 00 00"))}'
> > 274
>
> > To create the mktime() date string from the above format use split().
>
> > Janis
> > > Thanks for any help
>
> > > sKurt
>
> Sorry, in a DOS/WINDOWS world here, where do I get split()  That is a
> Gawk command?  Sorry, I haven't checked just yet.

Oh, I assumed you know about awk basics since you post in this group.

split() is indeed an awk function. If your date is in a variable d
then

    split(d,a,"/")

will assign the components which are separated by a / to the array a
and you can catenate the components to produce the mktime() string by

    mktime(a[3]" "a[1]" "a[2]" 0 0 0")


Janis

>
> Thanks again
>
> sKurt
>
> --


0
Reply Janis 10/1/2007 2:36:09 PM

Janis wrote:

> On 1 Okt., 16:11, "sKurt" <sK...@REMOVE.inbox.com> wrote:
> > Janis wrote:
> > 
> > > > I'd really like to convert the dates to a date number i.e.;
> > 
> > > > 01/01/2007 - DAY OF YEAR = 1
> > > > 01/31/2007 - DAY OF YEAR = 31
> > > > 10/01/2007 - DAY OF YEAR = 274
> > > > 12/31/2007 - DAY OF YEAR = 365
> > 
> > > $ gawk 'BEGIN{print strftime("%j",mktime("2007 10 01 00 00 00"))}'
> > > 274
> > 
> > > To create the mktime() date string from the above format use
> > > split().
> > 
> > > Janis
> > > > Thanks for any help
> > 
> > > > sKurt
> > 
> > Sorry, in a DOS/WINDOWS world here, where do I get split()  That is
> > a Gawk command?  Sorry, I haven't checked just yet.
> 
> Oh, I assumed you know about awk basics since you post in this group.
> 
> split() is indeed an awk function. If your date is in a variable d
> then
> 
>     split(d,a,"/")
> 
> will assign the components which are separated by a / to the array a
> and you can catenate the components to produce the mktime() string by
> 
>     mktime(a[3]" "a[1]" "a[2]" 0 0 0")
> 
> 
> Janis
> 
> > 
> > Thanks again
> > 
> > sKurt
> > 
> > --

First post in this group... I know enough about gawk that I glean from
the internet/google to find how to do what I need, someone suggested
this group to answer my question so here I am ;)

So my date as a variable d = 09/27/2007  OR in Win98 d = 09-27-2007
I convert using gawk or sed from '-' to '/' then

gawk split(d,a,"/") | gawk 'BEGIN{print strftime("%j",mktime("2007 10
01 00 00 00"))}'


would convert the variable d from 10/01/2007 to 274?  I'll play with
this some and do other research for split and mktime as now that I have
found it I may need it in the future ;)

thanks again

sKurt

-- 

0
Reply sKurt 10/1/2007 3:12:03 PM

sKurt wrote:
> Janis wrote:
> 
> 
>>On 1 Okt., 16:11, "sKurt" <sK...@REMOVE.inbox.com> wrote:
>>
>>>Janis wrote:
>>>
>>>
>>>>>I'd really like to convert the dates to a date number i.e.;
>>>
>>>>>01/01/2007 - DAY OF YEAR = 1
>>>>>01/31/2007 - DAY OF YEAR = 31
>>>>>10/01/2007 - DAY OF YEAR = 274
>>>>>12/31/2007 - DAY OF YEAR = 365
>>>
>>>>$ gawk 'BEGIN{print strftime("%j",mktime("2007 10 01 00 00 00"))}'
>>>>274
>>>
>>>>To create the mktime() date string from the above format use
>>>>split().
>>>
>>>>Janis
>>>>
>>>>>Thanks for any help
>>>
>>>>>sKurt
>>>
>>>Sorry, in a DOS/WINDOWS world here, where do I get split()  That is
>>>a Gawk command?  Sorry, I haven't checked just yet.
>>
>>Oh, I assumed you know about awk basics since you post in this group.
>>
>>split() is indeed an awk function. If your date is in a variable d
>>then
>>
>>    split(d,a,"/")
>>
>>will assign the components which are separated by a / to the array a
>>and you can catenate the components to produce the mktime() string by
>>
>>    mktime(a[3]" "a[1]" "a[2]" 0 0 0")
>>
>>
>>Janis
>>
>>
>>>Thanks again
>>>
>>>sKurt
>>>
>>>--
> 
> 
> First post in this group... I know enough about gawk that I glean from
> the internet/google to find how to do what I need, someone suggested
> this group to answer my question so here I am ;)

(No offense was intended :-)

> 
> So my date as a variable d = 09/27/2007  OR in Win98 d = 09-27-2007
> I convert using gawk or sed from '-' to '/' then
> 
> gawk split(d,a,"/") | gawk 'BEGIN{print strftime("%j",mktime("2007 10
> 01 00 00 00"))}'

No, rather (in Unix)...

   gawk -v d=09/27/2007 '
     BEGIN{split(d,a,"/"); x = mktime(a[3]" "a[1]" "a[2]" 0 0 0")}
   '
   # do anything with x, like print x, x-y, where y is another date,
   # use strftime() to get specific output, whatever...

In Windows there are quoting issues, so put the line BEGIN{...} in a
file fff.awk and call it as

   gawk -v d=09/27/2007 -f fff.awk

Not quite sure whether variable passing in Windows works the same way
using -v or whether you have to use /v or such.

If you want differences you may want a second variable -v d2=01/01/2007
and a second pair of mktime() calls.

Janis

> 
> 
> would convert the variable d from 10/01/2007 to 274?  I'll play with
> this some and do other research for split and mktime as now that I have
> found it I may need it in the future ;)
> 
> thanks again
> 
> sKurt
> 
0
Reply Janis 10/1/2007 3:42:40 PM

Janis Papanagnou wrote:


> 
> (No offense was intended :-)  - none taken, hope it didn't seem that
way :-o


> 
> > 
> > So my date as a variable d = 09/27/2007  OR in Win98 d = 09-27-2007
> > I convert using gawk or sed from '-' to '/' then
> > 
> > gawk split(d,a,"/") | gawk 'BEGIN{print strftime("%j",mktime("2007
> > 10 01 00 00 00"))}'
> 
> No, rather (in Unix)...
> 
>   gawk -v d=09/27/2007 '
>     BEGIN{split(d,a,"/"); x = mktime(a[3]" "a[1]" "a[2]" 0 0 0")}
>   '
>   # do anything with x, like print x, x-y, where y is another date,
>   # use strftime() to get specific output, whatever...
> 
> In Windows there are quoting issues, so put the line BEGIN{...} in a
> file fff.awk and call it as
> 
>   gawk -v d=09/27/2007 -f fff.awk
> 
> Not quite sure whether variable passing in Windows works the same way
> using -v or whether you have to use /v or such.
> 
> If you want differences you may want a second variable -v
> d2=01/01/2007 and a second pair of mktime() calls.
> 
> Janis
> 

Here is what I tried and what I ended up with.

>>fff.awk echo BEGIN{split(d,a,"/"); x = mktime(a[3]" "a[1]" "a[2" 0 0
0")]

gawk -v d=09/01/2007 -f fff.awk


gawk: fff.awk:1: fatal: function 'mktime' not defined

gawk 'BEGIN{printf d - d2}'
0


If I include the ' char at 'BEGIN... )}' and ending of the line
I get the following error

gawk: fff.awk:3: ^ Invalid char ''' in expression

So I deleted the ' char in the above line

My Windows variable is %l% and %u% so I hope to end up with

gawk 'BEGIN{split(%u%,a,"/"), ............

thanks

sKurt

-- 

0
Reply sKurt 10/1/2007 4:33:27 PM

Janis Papanagnou wrote:

> sKurt wrote:
> > Janis wrote:
> > 
> > 
> >>On 1 Okt., 16:11, "sKurt" <sK...@REMOVE.inbox.com> wrote:
> > > 
> > > > Janis wrote:
> > > > 
> > > > 
> > > > > > I'd really like to convert the dates to a date number i.e.;
> > > > 
> > > > > > 01/01/2007 - DAY OF YEAR = 1
> > > > > > 01/31/2007 - DAY OF YEAR = 31
> > > > > > 10/01/2007 - DAY OF YEAR = 274
> > > > > > 12/31/2007 - DAY OF YEAR = 365
> > > > 
> > > > > $ gawk 'BEGIN{print strftime("%j",mktime("2007 10 01 00 00
> > > > > 00"))}' 274
> > > > 
> > > > > To create the mktime() date string from the above format use
> > > > > split().
> > > > 
> > > > > Janis
> > > > > 
> > > > > > Thanks for any help
> > > > 
> > > > > > sKurt
> > > > 
> > > > Sorry, in a DOS/WINDOWS world here, where do I get split()
> > > > That is a Gawk command?  Sorry, I haven't checked just yet.
> > > 
> > > Oh, I assumed you know about awk basics since you post in this
> > > group.
> > > 
> > > split() is indeed an awk function. If your date is in a variable d
> > > then
> > > 
> >>   split(d,a,"/")
> > > 
> > > will assign the components which are separated by a / to the
> > > array a and you can catenate the components to produce the
> > > mktime() string by
> > > 
> >>   mktime(a[3]" "a[1]" "a[2]" 0 0 0")
> > > 
> > > 
> > > Janis
> > > 
> > > 
> > > > Thanks again
> > > > 
> > > > sKurt
> > > > 
> > > > --
> > 
> > 
> > First post in this group... I know enough about gawk that I glean
> > from the internet/google to find how to do what I need, someone
> > suggested this group to answer my question so here I am ;)
> 
> (No offense was intended :-)
> 
> > 
> > So my date as a variable d = 09/27/2007  OR in Win98 d = 09-27-2007
> > I convert using gawk or sed from '-' to '/' then
> > 
> > gawk split(d,a,"/") | gawk 'BEGIN{print strftime("%j",mktime("2007
> > 10 01 00 00 00"))}'
> 
> No, rather (in Unix)...
> 
>   gawk -v d=09/27/2007 '
>     BEGIN{split(d,a,"/"); x = mktime(a[3]" "a[1]" "a[2]" 0 0 0")}
>   '
>   # do anything with x, like print x, x-y, where y is another date,
>   # use strftime() to get specific output, whatever...
> 
> In Windows there are quoting issues, so put the line BEGIN{...} in a
> file fff.awk and call it as
> 
>   gawk -v d=09/27/2007 -f fff.awk
> 
> Not quite sure whether variable passing in Windows works the same way
> using -v or whether you have to use /v or such.
> 
> If you want differences you may want a second variable -v
> d2=01/01/2007 and a second pair of mktime() calls.
> 
> Janis
> 
> > 
> > 
> > would convert the variable d from 10/01/2007 to 274?  I'll play with
> > this some and do other research for split and mktime as now that I
> > have found it I may need it in the future ;)
> > 
> > thanks again
> > 
> > sKurt
> > 

String = "10/01/2007"
split( String, Array, "/" )
String = Array[ 1 ] " " Array[ 2 ] " " Array[ 3 ] " 00 00 00"

Still playing

sKurt

-- 

0
Reply sKurt 10/1/2007 8:35:08 PM

sKurt wrote:
> Janis Papanagnou wrote:
> 
> 
> 
>>(No offense was intended :-)  - none taken, hope it didn't seem that
> 
> way :-o
> 
> 
> 
>>>So my date as a variable d = 09/27/2007  OR in Win98 d = 09-27-2007
>>>I convert using gawk or sed from '-' to '/' then
>>>
>>>gawk split(d,a,"/") | gawk 'BEGIN{print strftime("%j",mktime("2007
>>>10 01 00 00 00"))}'
>>
>>No, rather (in Unix)...
>>
>>  gawk -v d=09/27/2007 '
>>    BEGIN{split(d,a,"/"); x = mktime(a[3]" "a[1]" "a[2]" 0 0 0")}
>>  '
>>  # do anything with x, like print x, x-y, where y is another date,
>>  # use strftime() to get specific output, whatever...
>>
>>In Windows there are quoting issues, so put the line BEGIN{...} in a
>>file fff.awk and call it as
>>
>>  gawk -v d=09/27/2007 -f fff.awk
>>
>>Not quite sure whether variable passing in Windows works the same way
>>using -v or whether you have to use /v or such.
>>
>>If you want differences you may want a second variable -v
>>d2=01/01/2007 and a second pair of mktime() calls.
>>
>>Janis
>>
> 
> 
> Here is what I tried and what I ended up with.
> 
> 
>>>fff.awk echo BEGIN{split(d,a,"/"); x = mktime(a[3]" "a[1]" "a[2" 0 0

What are you doing here? Where's the echo from? What is that strange
syntax supposed to mean?

> 
> 0")]
> 
> gawk -v d=09/01/2007 -f fff.awk
> 
> 
> gawk: fff.awk:1: fatal: function 'mktime' not defined

It's impossible to see whether that's an effect of the above illegal
syntax or whther your GNU awk version does not yet support mktime().
In the former case retry what I suggested, in the latter case update
your GNU awk version or see the FAQ of the newsgroup comp.unix.shell
for all questions about general date arithmetic.

> 
> gawk 'BEGIN{printf d - d2}'
> 0

Both variables, d and d2, are initially 0 so the result is to be
expected. The above is not much of a program, all the essentials I
posted are missing.

To repeat; on Windows it's really advisable to put the awk programs
in a file to avoid quoting problems.

> 
> 
> If I include the ' char at 'BEGIN... )}' and ending of the line
> I get the following error
> 
> gawk: fff.awk:3: ^ Invalid char ''' in expression
> 
> So I deleted the ' char in the above line
> 
> My Windows variable is %l% and %u% so I hope to end up with
> 
> gawk 'BEGIN{split(%u%,a,"/"), ............

If possible pass DOS batch variables to awk using awk variables; I
think in a DOS command window it might be called as

   gawk -v d=%u% -v d2=%v% -f fff.awk

for two DOS variables %u% and %v%. The file fff.awk may contain, e.g.

   BEGIN {
     split(d,a,"/")
     x = mktime(a[3]" "a[1]" "a[2]" 0 0 0")
     i = strftime("%j",x)

     split(d2,b,"/")
     y = mktime(b[3]" "b[1]" "b[2]" 0 0 0")
     j = strftime("%j",y)

     print i - j
   }

Works for me. If you have problems with your awk version see note above.

Janis

> 
> thanks
> 
> sKurt
> 
0
Reply Janis 10/1/2007 10:37:21 PM

sKurt wrote:
> Janis Papanagnou wrote:
> 
> 
>>sKurt wrote:
>>
>>>Janis wrote:
>>>
>>>
>>>
>>>>On 1 Okt., 16:11, "sKurt" <sK...@REMOVE.inbox.com> wrote:
>>>>
>>>>
>>>>>Janis wrote:
>>>>>
>>>>>
>>>>>
>>>>>>>I'd really like to convert the dates to a date number i.e.;
>>>>>
>>>>>>>01/01/2007 - DAY OF YEAR = 1
>>>>>>>01/31/2007 - DAY OF YEAR = 31
>>>>>>>10/01/2007 - DAY OF YEAR = 274
>>>>>>>12/31/2007 - DAY OF YEAR = 365
>>>>>
>>>>>>$ gawk 'BEGIN{print strftime("%j",mktime("2007 10 01 00 00
>>>>>>00"))}' 274
>>>>>
>>>>>>To create the mktime() date string from the above format use
>>>>>>split().
>>>>>
>>>>>>Janis
>>>>>>
>>>>>>
>>>>>>>Thanks for any help
>>>>>
>>>>>>>sKurt
>>>>>
>>>>>Sorry, in a DOS/WINDOWS world here, where do I get split()
>>>>>That is a Gawk command?  Sorry, I haven't checked just yet.
>>>>
>>>>Oh, I assumed you know about awk basics since you post in this
>>>>group.
>>>>
>>>>split() is indeed an awk function. If your date is in a variable d
>>>>then
>>>>
>>>>  split(d,a,"/")
>>>>
>>>>will assign the components which are separated by a / to the
>>>>array a and you can catenate the components to produce the
>>>>mktime() string by
>>>>
>>>>  mktime(a[3]" "a[1]" "a[2]" 0 0 0")
>>>>
>>>>
>>>>Janis
>>>>
>>>>
>>>>
>>>>>Thanks again
>>>>>
>>>>>sKurt
>>>>>
>>>>>--
>>>
>>>
>>>First post in this group... I know enough about gawk that I glean
>>>from the internet/google to find how to do what I need, someone
>>>suggested this group to answer my question so here I am ;)
>>
>>(No offense was intended :-)
>>
>>
>>>So my date as a variable d = 09/27/2007  OR in Win98 d = 09-27-2007
>>>I convert using gawk or sed from '-' to '/' then
>>>
>>>gawk split(d,a,"/") | gawk 'BEGIN{print strftime("%j",mktime("2007
>>>10 01 00 00 00"))}'
>>
>>No, rather (in Unix)...
>>
>>  gawk -v d=09/27/2007 '
>>    BEGIN{split(d,a,"/"); x = mktime(a[3]" "a[1]" "a[2]" 0 0 0")}
>>  '
>>  # do anything with x, like print x, x-y, where y is another date,
>>  # use strftime() to get specific output, whatever...
>>
>>In Windows there are quoting issues, so put the line BEGIN{...} in a
>>file fff.awk and call it as
>>
>>  gawk -v d=09/27/2007 -f fff.awk
>>
>>Not quite sure whether variable passing in Windows works the same way
>>using -v or whether you have to use /v or such.
>>
>>If you want differences you may want a second variable -v
>>d2=01/01/2007 and a second pair of mktime() calls.
>>
>>Janis
>>
>>
>>>
>>>would convert the variable d from 10/01/2007 to 274?  I'll play with
>>>this some and do other research for split and mktime as now that I
>>>have found it I may need it in the future ;)
>>>
>>>thanks again
>>>
>>>sKurt
>>>
> 
> 
> String = "10/01/2007"
> split( String, Array, "/" )
> String = Array[ 1 ] " " Array[ 2 ] " " Array[ 3 ] " 00 00 00"
> 
> Still playing
> 
> sKurt
> 

You already saw the answer to your question in the much earlier thread 
you responded to:

           http://tinyurl.com/2r5oep

so it's not clear why you're still playing or where your confusion lies. 
Why not try EXACTLY what was in that thread and then ask a specific 
question?

	Ed.
0
Reply Ed 10/2/2007 4:47:54 AM

Ed Morton wrote:


> > 
> 
> You already saw the answer to your question in the much earlier
> thread you responded to:
> 
>           http://tinyurl.com/2r5oep
> 
> so it's not clear why you're still playing or where your confusion
> lies. Why not try EXACTLY what was in that thread and then ask a
> specific question?
> 
> 	Ed.




probably because I have been hit from this thread and the
alt.msdos.batch thread with many excellent suggestions and I haven't
had time to try them all.

Also while I get by by looking up on the internet for 'one liner' gawk
code to assist me in my quest to improve/enhance these batches I work
on, I am not anywhere near the expert of you or Janis and when the
answer is shoved in my face I can't see the forest for the trees ;)

I do appreciate all the help everyone imparts to me and I try to give
thanks as much as I can, I am getting more and more comfortable with
gawk I used to use sed more but they tell me sed is based on gawk so
why not do gawk.  And here I am.


Thanks for pointing out the obvious, I really have not had the chance
to try it so it may work just fine for me.  I also found another from
the Timo Salmi listing that is also supposed to work, just in case
anyone else like me is lurking and would like another shot in another
way.


gawk 'BEGIN{printf"@set
wn_=%%s\n",strftime("%%V",systime())}'>tmp$$$.bat

  call tmp$$$

  ::

  :: Show the result

  set|find "WN_"

  ::

  :: Clean up

  for %%f in (tmp$$$.bat) do if exist %%f del %%f

  set wn_= 


But even this answer which is also probably the answer to the question
and I haven't hit that one either. :(


I am sincere here I really do appreciate all the help here.

Thanks much!

sKurt
-- 

0
Reply sKurt 10/2/2007 5:57:45 AM

Ed Morton wrote:


> 
> You already saw the answer to your question in the much earlier
> thread you responded to:
> 
>           http://tinyurl.com/2r5oep
> 
> so it's not clear why you're still playing or where your confusion
> lies. Why not try EXACTLY what was in that thread and then ask a
> specific question?
> 
> 	Ed.


Oh and really quickly I tried;

gawk 'BEGIN{printf"@set wn_=%%s\n",strftime("%%j",systime())}'

and it gave the date number of today 274, however, I still need the
date that I specify as well  like 09/01/2007 or 05/04/2007.

and I am sure the answer as already been solved and now is the time for
me to try the rest of the suggestions

Thanks

sKurt

-- 

0
Reply sKurt 10/2/2007 6:07:23 AM

Ed Morton wrote:

> You already saw the answer to your question in the much earlier
> thread you responded to:
> 
>           http://tinyurl.com/2r5oep
> 
> so it's not clear why you're still playing or where your confusion
> lies. Why not try EXACTLY what was in that thread and then ask a
> specific question?
> 
> 	Ed.



Last for the evening, promise ;)  Turns out I was using 

GAWK 2.15 patch 6 which probably didn't have the mktime()

but just downloaded;

GAWK 3.1.3-2 so hopefully that will have what is required...

Thanks

sKurt

-- 

0
Reply sKurt 10/2/2007 6:27:21 AM

Janis Papanagnou wrote:


> 
> If possible pass DOS batch variables to awk using awk variables; I
> think in a DOS command window it might be called as
> 
>   gawk -v d=%u% -v d2=%v% -f fff.awk
> 
> for two DOS variables %u% and %v%. The file fff.awk may contain, e.g.
> 
>   BEGIN {
>     split(d,a,"/")
>     x = mktime(a[3]" "a[1]" "a[2]" 0 0 0")
>     i = strftime("%j",x)
> 
>     split(d2,b,"/")
>     y = mktime(b[3]" "b[1]" "b[2]" 0 0 0")
>     j = strftime("%j",y)
> 
>     print i - j
>   }
> 
> Works for me. If you have problems with your awk version see note
> above.
> 
> Janis
> 
> > 

> > 


Sorry Janis,

I think the confusion is that I am using DOS/Windows and you are
showing me 'nix examples and things like >>fff.awk ECHO 'BEGIN...  mean
to
create a file called fff.awk and put everything after ECHO into that
file.

Also I was using an old 2.15 version from 1995 and have just downloaded
the new 3.1.3 version from sourceforge and I'll give that a try.  I
think, I'd rather use a stand-alone gawk and it looks like the new gawk
uses a dll along with the .exe file?  I'll check to see what version
has the mktime() function as well as not needing the .dll

I appreciate the help given!

sKurt
-- 

0
Reply sKurt 10/2/2007 3:26:17 PM

On Tue, 02 Oct 2007 15:26:17 +0000, sKurt wrote:

> Also I was using an old 2.15 version from 1995 and have just downloaded
> the new 3.1.3 version from sourceforge and I'll give that a try.  I think,
> I'd rather use a stand-alone gawk and it looks like the new gawk uses a
> dll along with the .exe file?  I'll check to see what version has the
> mktime() function as well as not needing the .dll

<ftp://garbo.uwasa.fi/win95/unix/UnxUpdates.zip> contains a stand alone
version of 3.1.3.

-- 
T.E.D. (tdavis@umr.edu)


0
Reply Ted 10/2/2007 8:06:17 PM

Ted Davis wrote:

> On Tue, 02 Oct 2007 15:26:17 +0000, sKurt wrote:
> 
> > Also I was using an old 2.15 version from 1995 and have just
> > downloaded the new 3.1.3 version from sourceforge and I'll give
> > that a try.  I think, I'd rather use a stand-alone gawk and it
> > looks like the new gawk uses a dll along with the .exe file?  I'll
> > check to see what version has the mktime() function as well as not
> > needing the .dll
> 
> <ftp://garbo.uwasa.fi/win95/unix/UnxUpdates.zip> contains a stand
> alone version of 3.1.3.

Thanks Ted, grabbed it up!  I also see it has sed, I'll have to check
that version as well :)

sKurt

-- 

0
Reply sKurt 10/2/2007 8:40:32 PM

16 Replies
296 Views

(page loaded in 0.326 seconds)

Similiar Articles:


















7/25/2012 12:15:54 AM


Reply: