i tried below function but I am still getting the week day as number,(1, 2,etc) but i need to get weekday as MON, TUE, WEd etc.
I Used the TimestampToString() function to change to string and then did the Code:
FIELD(date, "-", 2, 1)
Timestamp to week day in String (mon, tue)
Moderators: chulett, rschirm, roy
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
You do NOT require a string, because the weekday name is not part of a timestamp.
You need to extract the date part from the timestamp, then the weekday number from the date, then the weekday name from the weekday number, as I described the last time this question was posted.
You need to extract the date part from the timestamp, then the weekday number from the date, then the weekday name from the weekday number, as I described the last time this question was posted.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
You should have just stayed in your original thread. No reason to start a new one and break the relationship, one to the other.
Are you trying to follow Ray's advice there? What was your exact TimestampToString function used? The FIELD function just returns a portion of a delimited string and was meant to be used in conjunction with a 'day of the week' number determined earlier. Specifically -
If you know that 1 = Sunday, 2 = Monday, 3 = Tuesday, etc then use the field function more like:
Where DayNumber is the value determined ealier.
Are you trying to follow Ray's advice there? What was your exact TimestampToString function used? The FIELD function just returns a portion of a delimited string and was meant to be used in conjunction with a 'day of the week' number determined earlier. Specifically -
If you know that 1 = Sunday, 2 = Monday, 3 = Tuesday, etc then use the field function more like:
Code: Select all
FIELD('SUN,MON,TUE,WED,THU,FRI,SAT',',',DayNumber,1)
-craig
"You can never have too many knives" -- Logan Nine Fingers
"You can never have too many knives" -- Logan Nine Fingers
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
... except that day number is zero-based (what isn't?)
So you will need a slight adjustment on Craig's Field() function. You can decide which day is the first in the week, which will cause the list of day name abbreviations to be different, appropriate to your locale.
So you will need a slight adjustment on Craig's Field() function. You can decide which day is the first in the week, which will cause the list of day name abbreviations to be different, appropriate to your locale.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Thanks for your help. I used the following but still getting weekday number (that is also not right, repeating the same numbers 1,2,3 for any date value). I think I am missing something. Please correct me.
FIELD('SUN,MON,TUE,WED,THU,FRI,SAT',',', WeekdayFromDate(TimestampToDate(INVENTORY_TIMESTAMP)) ,1)
FIELD('SUN,MON,TUE,WED,THU,FRI,SAT',',', WeekdayFromDate(TimestampToDate(INVENTORY_TIMESTAMP)) ,1)
-
- Participant
- Posts: 54607
- Joined: Wed Oct 23, 2002 10:52 pm
- Location: Sydney, Australia
- Contact:
Should not INVENTORY_TIMESTAMP be qualified with the input link name?
Try it a piece at a time.
Does TimestampToDate() work?
Then does applying WeekdayFromDate() work applied to that result?
Only then apply the Field() function.
Put the results into stage variables; put them on separate output columns while testing. You can simply eliminate these columns once you've got it working.
You may also need to add 1 to the third argument of Field(), since WeekdayFromDate() returns a zero-based count.
Try it a piece at a time.
Does TimestampToDate() work?
Then does applying WeekdayFromDate() work applied to that result?
Only then apply the Field() function.
Put the results into stage variables; put them on separate output columns while testing. You can simply eliminate these columns once you've got it working.
You may also need to add 1 to the third argument of Field(), since WeekdayFromDate() returns a zero-based count.
IBM Software Services Group
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.
Any contribution to this forum is my own opinion and does not necessarily reflect any position that IBM may hold.