Day Number of the week

source1ben
Posts: 32
Joined: Fri Nov 02, 2001 10:22 am

Day Number of the week

Post by source1ben »

I'm trying to get the Day-Number-of-the-Week. I'm not having any luck with my attempts.

Here is my code.

<strfmt "%w" "now">
<$daynumber = $ret>
daynumber: $daynumber

I get the following error " Too many arguments for <strfmt> string"

My code works fine with a capital W, but I'm not looking for the Day-Number-of-the-Month.

Any ideas ?
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

Day Number of the week

Post by mark »

The proper way to print times is with %t , then your time format. Some time formats that don't conflict with other things are "auto" recognized, but it's not good practice to rely on that. Use
<strfmt "%at" "%w" "now">
source1ben
Posts: 32
Joined: Fri Nov 02, 2001 10:22 am

Day Number of the week

Post by source1ben »

Works like a charm.

thx.

Ben
User avatar
John
Site Admin
Posts: 2623
Joined: Mon Apr 24, 2000 3:18 pm
Location: Cleveland, OH

Day Number of the week

Post by John »

Note also that this is available as the SQL function dayofweek(), allowing SQL statements such as:

SELECT dayofweek(Date) from ....

and Vortex such as:

<$daynumber=(dayofweek( 'now' ))>
John Turnbull
Thunderstone Software
source1ben
Posts: 32
Joined: Fri Nov 02, 2001 10:22 am

Day Number of the week

Post by source1ben »

FYI- I get different results from the two different version of the code.

<strfmt "%at" "%w" "now">

returns: 5

<$daynumber=(dayofweek( 'now' ))>

returns: 6

Either method will solve my problem. Thx again.
User avatar
mark
Site Admin
Posts: 5519
Joined: Tue Apr 25, 2000 6:56 pm

Day Number of the week

Post by mark »

fmt "days" range is 0-6 (a programming standard), dayofweek() range is 1-7 (a SQL standard).