>>>>This logic has been in the business of the application for a long time and works well. Each month has from 4 to 5 weeks, or better said, has 4 to 5 Mondays. Therefore, in this logic given that the Monday Number (1 to 5 ) is known and the month, the program needs to know the week number in a year. Example
>>>>Month: September
>>>>Week: 1 (which is the week of September 4th, 2017)
>>>>And I need to find the week number in a year. I know it is a week 36 this year. But I need to find the way to determine this in T-SQL language. So that the setting can be done in one SQL Server update/insert statement.
>>>>
>>>>If this is not possible, I will have to do it from VFP PRG code, which is not that difficult.
>>>>
>>>>>I get the feeling that you are painting yourself into a corner using somewhat arbitrary definitions like month week ;-)
>>>>>Meditate on the biz need for month week and probably save the date in the DB.
>>>>>If you need fast grouping, index to special tags via formula from saved date.
>>>>>Or perhaps create virtual fields from the date...
>>>>>
>>>>>>Hi,
>>>>>>
>>>>>>I found (online) the following code that determines the month number by Week and Year.
>>>>>>
>>>>>>declare @Year char(4), @Week tinyint
>>>>>>select @Year = '2003', @Week = 10
>>>>>>select month(dateadd(wk,@Week,@Year + '/01/01'))
>>>>>>
>>>>>>
>>>>>>How would I use the above expression or is there another expression that will give me the Week Number (in a year, 1-52) if the Month Number (e.g. 1 to 12) is known and the Week Number in the month (1-5)?
>>>>>>
>>>>>>TIA
>>>
>>>Will this do it:
https://stackoverflow.com/questions/42794544/get-week-number-in-year-from-date ?
>>>Note the last answer which includes 'set datefirst'
>>
>>This may provide the answer to my question if I figure how to get the Date from the number of a Monday in a month. Like, what is the date of the 2nd Monday of September 2017.
>>Thank you.
>
>I'm not a SQL man but isn't that what 'set datefirst' does?
>
>
https://docs.microsoft.com/en-us/sql/t-sql/statements/set-datefirst-transact-sqlThank you very much. I will see how this could help me with my question.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham