Page 1 of 1
retrieving the day of week number
Posted: Wed Mar 08, 2017 2:53 pm
by monahanks
Good afternoon,
I need to retrieve the day of the week (1 through 7) from the current date to use as a file extension. Using the date format of 'F' in a timestamp expression today (Wednesday) is always returning a value of '2' instead of '4'. What am I missing in this? My code is:
<timestamp version="1.0" disabled="false">
<format outputVariable="DW_DAY" pattern="F" />
</timestamp>
TIA,
Kevin
Re: retrieving the day of week number
Posted: Thu Mar 09, 2017 9:32 am
by monahanks
Maybe I'm misunderstanding the purpose of this value - I think it is telling me the number of occurrences of the day of the week within that month? So it is telling me that it is the second Wednesday of the month?
If so, is there a function that will tell me what day of the week it is, like '1' is Sunday, '2' is Monday, '5' is Thursday, etc? Or do I need a table that produces that?
Thanks,
Kevin
Re: retrieving the day of week number
Posted: Thu Mar 09, 2017 9:50 am
by Support_Rick
Kevin,
The option "E" allows you to get the "Day of the Week" (Sun, Mon, Tue, Wed, etc) which could give you the xref into 1,2,3,4.
Will that work?
Re: retrieving the day of week number
Posted: Thu Mar 09, 2017 12:12 pm
by monahanks
Thanks Rick, I guess it will have to work. I can make an xref table based on the day name to get the number. The user may want to have Monday = Day 1, so an xref would work better anyway in that situation.
Re: retrieving the day of week number
Posted: Thu Mar 09, 2017 1:02 pm
by Support_Rick
Try using a "u" instead... looks like there might be a Java Bug.
${CurrentDate('u')}
That should give you what you're looking for
Re: retrieving the day of week number
Posted: Thu Mar 09, 2017 2:47 pm
by monahanks
Hi Rick,
this subtracted a day from the current date? maybe I'm not using it right... I think the xref will give me what I (and the user) need.
xml code =
<timestamp version="1.0">
<format outputVariable="DU_DAY" dayOfWeek="${CurrentDate('u')}" />
</timestamp>
Result = Timestamp variable 'DU_DAY' was created and set to '2017-03-08 14:44:29.743'
Re: retrieving the day of week number
Posted: Thu Mar 09, 2017 11:51 pm
by Support_Rick
No, you don't need the "TimeStamp" task with that. Just use the function where you need it...
Like:
SetVariable DU_Day : Value="${CurrentDate('u')}"