473,383 Members | 1,829 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Giorni della settimana

devo passare all'SQL una stringa where che mi applichi delle modifiche
in un range di data ma soltanto il martedi e il venerdì per esempio,
opppure soltanto il giovedì e la domenica: Riporto un esempio:

......
......
......
WHERE DATA BETWEEN 'Datainizio' AND 'DataFine' AND
...............................

come gli passo dopo l'AND i giorni della settimana?
In VB posso distinguere i giorni con Weekbday ma mi serve un consiglio
per completare la clausola where.

Thanks!!!!
Jul 20 '05 #1
2 5145
[posted and mailed]

Yachi (ya***@pointel.it) writes:
devo passare all'SQL una stringa where che mi applichi delle modifiche
in un range di data ma soltanto il martedi e il venerdì per esempio,
opppure soltanto il giovedì e la domenica: Riporto un esempio:

.....
.....
.....
WHERE DATA BETWEEN 'Datainizio' AND 'DataFine' AND
..............................

come gli passo dopo l'AND i giorni della settimana?
In VB posso distinguere i giorni con Weekbday ma mi serve un consiglio
per completare la clausola where.


WHERE datepart(weekday, data) BETWEEN 3 AND 4

Il result di datepart depende a SET DATEFIRST. Il default per us_english
è 7, che voule dire il result per giovedì è 5.
--
Erland Sommarskog, SQL Server MVP, so****@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 20 '05 #2
You can use DATEPART to determine the day of the week.
It is best to use @@datefirst in the query, in case
its value changes.

-- Monday and Thursday only
where...
and DATEPART(dw,getdate())+@@datefirst in (2, 5)

-- Saturday and Sunday only
where...
and DATEPART(dw,getdate())+@@datefirst in (1, 7)

-- Steve Kass
-- Drew University
-- Ref: C64FDB90-0033-436B-A3BB-FC338FAB382A
Yachi wrote:
devo passare all'SQL una stringa where che mi applichi delle modifiche
in un range di data ma soltanto il martedi e il venerdì per esempio,
opppure soltanto il giovedì e la domenica: Riporto un esempio:

.....
.....
.....
WHERE DATA BETWEEN 'Datainizio' AND 'DataFine' AND
..............................

come gli passo dopo l'AND i giorni della settimana?
In VB posso distinguere i giorni con Weekbday ma mi serve un consiglio
per completare la clausola where.

Thanks!!!!


Jul 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Mauro | last post by:
Ciao a tutti! vorrei sapere se qualcuno potrebbe darmi qualche dritta (o se sa dove reperire un tutorial) su come realizzare un trial a tempo, da integrare ad un mio programma per impedirne...
1
by: SAN CAZIANO | last post by:
selezionare il valore di una SELECT sapendo il testo che deve avere tra le sue opzioni <select name="combo"> <option>nome</option> <option>cognome</option> <option>prova</option>...
6
by: TC | last post by:
Hi. I write a program in c language that read a text file and extrapolate the word. for all word the program calculate the number of the times that word is present in the text. The problem is the...
3
by: TC | last post by:
I'm not a C programmer. This is a good C? how check the return value of getch or scanf? and how check for the \n at the end of the text read? FEOF do not return true if the file (text file) is...
6
by: Diego_Atos | last post by:
Hi you all. I've an asp.net control, a checkboxlist. I want to read "checked" properties for all items of my control. How can i do it? I read some tips on the net, but none of them works. ...
0
by: | last post by:
Hai un nuovo messaggio da Morena227. Per ascolto chiama da fisso lo 89-9030-521. Il messaggio rimarrà nel sistema per 15 giorni, poi si provvederà all'eliminazione. Lo Staff non è responsabile del...
1
by: fepino | last post by:
ciao a tutti ho un problema che da giorni non riesco a risolvere. Vorrei creare una query che mi selezioni i dati di una tabella in base a dei valori inseriti in una maschera. Non riesco ad...
2
by: reviglione | last post by:
Ciao a tutti, io ho una serie di progetti, ogni progetto ha le proprie risorse (dialog,menu,string table). Devo poter caricare le risorse di un progetto piuttosto che di un altro dinamicamente. Ho...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.