Focal Point
[SOLVED]Day of week from SQL Server Date field

This topic can be found at:
https://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/4017046386

August 29, 2016, 03:32 PM
Trudy
[SOLVED]Day of week from SQL Server Date field
I have a SQL server table that has a date field in it called LOADDATE. In the description of the column in SQL Server it says LOADDATE (date, not null)

When I have a DEFINE using the DOWK(LOADDATE, 'A4') I get blanks returned.
When I just report out the LOADDATE field I get 2016/08/29
When I substitute &YYMD in DOWK(&YYMD, 'A4') then MON is returned as it should be.
When I report out &YYMD by itself I get the date in the 2016/08/29 format.

So why if the two fields have the same format does the DOWK(LOADDATE, 'A4') not work?

Thanks Trudy

This message has been edited. Last edited by: Trudy,


WF8
Windows
August 29, 2016, 04:38 PM
Dan Satchell
DOWK expects the date in legacy I8YYMD format (like &YYMD). Your LOADDATE will be defined as a SmartDate in the FOCUS synonym. Try this to print the day of week for a SmartDate:

TABLE FILE xxxx
PRINT LOADDATE/WT
.
.
END



WebFOCUS 7.7.05
August 30, 2016, 09:11 AM
Trudy
The PRINT LOADDATE/WT did give me the day of the week but I want to filter on that value so I was looking more for a DEFINE way of getting to the day of week. Sorry I should have made that clearer in the original post.


WF8
Windows
August 30, 2016, 09:14 AM
dhagen
You could probably save yourself some trouble and use a SQL Server function

DEFINE FILE xxxx
 DOW/A10  WITH yyyy = DB_EXPR( DATENAME( dw,  START_DATE ) ); $ 
END  


It will be the full weekname in mixed case, but you can probably work with that. And there is no fear that it will not be translated.


"There is no limit to what you can achieve ... if you don’t care who gets the credit." Roger Abbott
August 30, 2016, 09:19 AM
Trudy
Got what I needed by creating a define with the following
  
DOWK(DATECVT(LOADDATE, 'YYMD', 'I8YYMD'), 'A4')


Thanks for all the help!


WF8
Windows