Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » ElevateDB Technical Support » Support Forums » ElevateDB SQL » View Thread |
Messages 1 to 2 of 2 total |
EXTRACT(DAYOFWEEK but using system first day of week |
Fri, Apr 17 2015 11:56 AM | Permanent Link |
Michael Fullerton | Suppose I have a table with a date field: DatePaid and a number field: AmountPaid. I need to break data up into weeks that take into account the system week start day. The EXTRACT(DAYOFWEEK is great but assumes a Monday week start. Can anyone think of a SQL only solution or am I stuck consolidating the data using a clientdataset?
|
Sat, Apr 18 2015 3:14 AM | Permanent Link |
Roy Lambert NLH Associates Team Elevate | Michael
>Suppose I have a table with a date field: DatePaid and a number field: AmountPaid. I need to break data up into weeks that take into account the system week start day. The EXTRACT(DAYOFWEEK is great but assumes a Monday week start. Can anyone think of a SQL only solution or am I stuck consolidating the data using a clientdataset? I'm assuming you miss typed EXTRACT(DAYOFWEEK and it should have been EXTRACT(WEEK, if so all you need is an offset to move the date you have back / forward by the difference between the system start date and Monday eg select _invoiced, extract(WEEK from _invoiced), extract(WEEK from _invoiced - INTERVAL '1' DAY) /* start the week on Sunday */ from invoices not quite SQL only since the offset passed to INTERVAL has to be a constant so you have to build the SQL rather than passing in a parameter Roy Lambert |
This web page was last updated on Monday, April 29, 2024 at 05:23 AM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |