Click here to Skip to main content
15,898,923 members
Home / Discussions / Database
   

Database

 
AnswerRe: restore database Pin
CHill6029-Jul-15 3:56
mveCHill6029-Jul-15 3:56 
QuestionRe: restore database Pin
Eddy Vluggen29-Jul-15 5:31
professionalEddy Vluggen29-Jul-15 5:31 
AnswerRe: restore database Pin
Mycroft Holmes29-Jul-15 14:30
professionalMycroft Holmes29-Jul-15 14:30 
AnswerRe: restore database Pin
Nitzan Levi22-Aug-15 20:20
Nitzan Levi22-Aug-15 20:20 
QuestionUpdate SQL Server Table with a Spreadsheet Worksheet DataTable using CommandBuilder Pin
LHendren27-Jul-15 1:37
LHendren27-Jul-15 1:37 
AnswerRe: Update SQL Server Table with a Spreadsheet Worksheet DataTable using CommandBuilder Pin
Mycroft Holmes27-Jul-15 14:33
professionalMycroft Holmes27-Jul-15 14:33 
QuestionSQL Linq, Joins, returns 1st record over and over Pin
jkirkerx23-Jul-15 9:11
professionaljkirkerx23-Jul-15 9:11 
Answer[Solved] Pin
jkirkerx23-Jul-15 11:30
professionaljkirkerx23-Jul-15 11:30 
QuestionEntity Framework Book. Pin
Kevin Marois23-Jul-15 5:29
professionalKevin Marois23-Jul-15 5:29 
QuestionRe: Entity Framework Book. Pin
Richard MacCutchan23-Jul-15 6:36
mveRichard MacCutchan23-Jul-15 6:36 
AnswerRe: Entity Framework Book. Pin
Kevin Marois23-Jul-15 7:31
professionalKevin Marois23-Jul-15 7:31 
AnswerRe: Entity Framework Book. Pin
Mycroft Holmes23-Jul-15 14:10
professionalMycroft Holmes23-Jul-15 14:10 
QuestionSQL Linq, select from select and join Pin
jkirkerx21-Jul-15 13:27
professionaljkirkerx21-Jul-15 13:27 
SuggestionRe: SQL Linq, select from select and join Pin
Richard Deeming22-Jul-15 1:50
mveRichard Deeming22-Jul-15 1:50 
GeneralRe: SQL Linq, select from select and join Pin
jkirkerx22-Jul-15 6:02
professionaljkirkerx22-Jul-15 6:02 
GeneralRe: SQL Linq, select from select and join Pin
Richard Deeming22-Jul-15 8:00
mveRichard Deeming22-Jul-15 8:00 
GeneralRe: SQL Linq, select from select and join Pin
jkirkerx22-Jul-15 9:04
professionaljkirkerx22-Jul-15 9:04 
QuestionTrouble working with dates again and union and sum Pin
jkirkerx20-Jul-15 13:08
professionaljkirkerx20-Jul-15 13:08 
AnswerRe: Trouble working with dates again and union and sum Pin
jkirkerx20-Jul-15 13:34
professionaljkirkerx20-Jul-15 13:34 
Generalmake nullable type Pin
jkirkerx20-Jul-15 13:59
professionaljkirkerx20-Jul-15 13:59 
General[Got It] Pin
jkirkerx21-Jul-15 9:58
professionaljkirkerx21-Jul-15 9:58 
GeneralThe above post is incorrect - SQL Linq, Date Range, Union in VB Pin
jkirkerx22-Jul-15 8:54
professionaljkirkerx22-Jul-15 8:54 
After testing with a real dataset, I was getting the wrong values.
For doing this in VB, you have to wrap the date range in (), in order to properly evaluate it.
So this produces the correct result, even if the value is 0.
I was banging my head against the wall trying to figure this one out.

Thanks to Richard Deeming for setting me straight on the DateTime.
Dim pValue As Decimal = 0

        Dim baseDate As DateTime = DateTime.Today()
        Dim dateStart As New DateTime(baseDate.Year, baseDate.Month, baseDate.Day, 0, 0, 0, 0)
        Dim dateStop As New DateTime(baseDate.Year, baseDate.Month, baseDate.Day, 23, 59, 59, 999)

        Using context As New hx5Context

            pValue = _
            (
                From oh In context.Order_History
                Where (oh.OrderDate = dateStart And oh.OrderDate <= dateStop) _
                And Not (oh.OrderStatus = "ORDER_CANCELED")
                Select oh.GrandTotal
            ).Union _
            (
                From oc In context.Order_Completed
                Where (oc.OrderDate >= dateStart And oc.OrderDate <= dateStop) _
                And
                (
                    oc.OrderStatus = "QUEUED_FOR_FULFILLMENT" _
                    Or oc.OrderStatus = "OUT_FOR_FULFILLMENT" _
                    Or oc.OrderStatus = "QUEUED_FOR_SHIPPING" _
                    Or oc.OrderStatus = "OUT_FOR_PACKAGING" _
                    Or oc.OrderStatus = "READY_TO_SHIP" _
                )
                Select oc.GrandTotal
            ).DefaultIfEmpty().Sum()

        End Using

        Return pValue

GeneralRe: The above post is incorrect - SQL Linq, Date Range, Union in VB Pin
Mycroft Holmes22-Jul-15 14:15
professionalMycroft Holmes22-Jul-15 14:15 
GeneralRe: The above post is incorrect - SQL Linq, Date Range, Union in VB Pin
jkirkerx23-Jul-15 6:38
professionaljkirkerx23-Jul-15 6:38 
GeneralRe: The above post is incorrect - SQL Linq, Date Range, Union in VB Pin
Brisingr Aerowing23-Jul-15 7:37
professionalBrisingr Aerowing23-Jul-15 7:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.