473,324 Members | 2,400 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,324 software developers and data experts.

How to show dates from Sunday through Saturday?

347 100+
I have the following query:

select MAX(payrolldate) AS [payrolldate], dateadd(dd, ((datediff(dd, '17530107', MAX(payrolldate))/7)*7)+7, '17530107') AS [Sunday] from dbo.payroll

and it's currently showing me from Sunday at 12:00 am through the following Sunday at 12:00 am and I need it to show me from Sunday at midnight to Saturday at midnight. I've tried to adjust this but I am obviously missing something. Can someone please assist me on this?

Thanks

Doug
Jan 19 '11 #1
4 2412
Rabbit
12,516 Expert Mod 8TB
You do realize that if you go from Sunday 12 AM to Saturday 12 AM that you lose everything that happens on Saturday right? Currently you overlap by one minute. If you use Saturday 12 AM then you lose 23 hours and 59 minutes and 59 seconds of data. If you the overlap is unacceptable but you want to keep the rest of the data, you can't use "midnight" as you call it. You have to just subtract one second from the date you currently have.
Jan 19 '11 #2
dougancil
347 100+
Rabbit,

So then if I want to remove that one second, how do I go about doing that? I'm presenting this information to end users and I think that they would be confused by the time span showing Sunday to Sunday. I think if I showed them Sunday to Saturday at 11:59:59 then they wouldn't "freak" out about it.
Jan 20 '11 #3
Rabbit
12,516 Expert Mod 8TB
Well, you already have the DateAdd function. Use another one to "add" -1 seconds.
Jan 20 '11 #4
ck9663
2,878 Expert 2GB
Are you going to use the range in a filter condition?

~~ CK
Jan 20 '11 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

11
by: Solomon Grundy | last post by:
Select trunc(sysdate,'MM') from dual of course gives me the first day of the month, may I ask what the query is to find the first saturday of the month?
8
by: netsurfer | last post by:
Hi: Have a question on making the date automatically filled in by what the user enters in by the date at the top. The date entered at the top would most likely be on a Wednesday then I need...
0
by: Jerry | last post by:
Given a week number of a selected year, how do I find the dates of the Sunday and Saturday of that week? Thanks! Jerry
3
by: Jerry | last post by:
How do I find the dates of the Sunday and Saturday of a week if I have the week number of a selected year? Thanks! Jerry
1
by: rock72 | last post by:
Hello Everyone, Can you tell me how to produce a query that when Login Date (entry) is Sunday. First, check if the Sunday Date occur on 7th day of his duty. Example 1: Login Date no. of...
1
by: MFRASER | last post by:
If I have a date how can I find out the beginning of the week and the end of the week? System.DateTime StartDate = new DateTime(2003,10,29); System.DateTime StartWeek = ? ...
14
by: jpr | last post by:
Friends, I have a form with four fields, date1, date2, date3 and date4. All these have all a mm/dd/yyyy format and have their source to a table. I need to add an unbound control (I will name...
3
by: Tim Chase | last post by:
I've been trying to come up with a good algorithm for determining the starting and ending dates given the week number (as defined by the strftime("%W") function). My preference would be for a...
4
by: jdph40 | last post by:
I enter data into a database that resides on our network. Other employees can print reports from the database, but they have no way of telling if I've entered all the data. For instance, on...
3
by: pchaitanya | last post by:
I have selected some list of valid dates to a label. now i need to find first day among the given dates from label contrl i got dates from calender control by clicking for entire week.. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
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...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
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...

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.