Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Find DOW in SQL Server?
Message
 
 
À
18/04/2024 07:16:47
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Divers
Thread ID:
01687856
Message ID:
01687902
Vues:
16
>>>>>>Hi,
>>>>>>
>>>>>>I want to specify in the SQL Select that Day of the Week in Monday. I know that in VFP it would be the function DOW().
>>>>>>That is, in VFP I would use
>>>>>>
>>>>>>where DOW(date_field) = 2
>>>>>>
>>>>>>What function could I use in SQL Server?
>>>>>>
>>>>>>TIA
>>>>>
>>>>>SET DATEFIRST = 1
>>>>>
>>>>>Check my answer to your previous question.
>>>>
>>>>Something I still do not understand. If you want to make sure that only Mondays are selected with a SQL Select, you would want to include Something in the WHERE expression. How do you use the "SET DATEFIRST .." in the WHERE expression of the SQL Select?
>>>
>>>No, SET DATEFIRST is to make sure what day is supposed to be first in the week Monday or any other.
>>>Check DATEPART() function.
>>
>>I found this page
>>
>>https://www.tutorialsteacher.com/sqlserver/datename
>>
>>and it appears that the DateName should return the DOW character value. But so far, I have not found how to use this function (DateName) to get only Mondays. I will keep working on this.
>>Thank you.
>
>Can you please post some example data and what you want from it?

I updated my post but I suppose you did not see it. I found that the parameter DW returns the integer of the Day of the Week, when applying this parameter to the DatePart() function. It is just that it seems to return 2 for Monday, 3 for Tuesday, and so on.
Is this how I should use the DatePart()? That is, to make sure that the DatePart( dw, date_field) returns 2 if I need only Mondays?

UPDATE. I see that the VFP's DOW() has the same values, 2 - for Monday, 3 - for Tuesday. So, the DatePart() with DW seems to match the DOW().
"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
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform