Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6174769
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T23:48:25+00:00 2026-05-23T23:48:25+00:00

I have a ms sql 2008 table with data from a weather datalogger. table

  • 0

I have a ms sql 2008 table with data from a weather datalogger.

table format

LogDate (nvarchar) 01/04/2010
LogTime (nvarchar) 10:00
LogMonth (nvarchar) APR
LogYear (nvarchar) 2010
Rain_Today (Double) 5.6

The daily reading for rain totals are at 08:59 the next day. So the table shows 5.6 mm for example: 03/04/2010 at 08:59, but this is actually the total for the previous day i.e. 02/04/2010. All the rain readings are a day out and the last day of the month’s value is shown for the first day of the next month.

Is there a way to list the above rain values for the date 02/04/2010 instead of 03/04/2010? The date and time columns are in string format. This code works fine but the dates are a day out as above.

Edit Fixed the code from bitwise & to conditional &&

var q = from c in context.Wxlogs
               where
               c.LogYear == year && c.LogMonth == month && c.Time.Contains("08:59")
               orderby c.LogDate                    
               select new {c.LogDate, c.Rain_today};

table data

Apr 2010 01/04/10 09:00 0.0
Apr 2010 01/04/10 09:01 0.0
Apr 2010 01/04/10 19:02 23.7
Apr 2010 02/04/10 00:03 23.8
Apr 2010 02/04/10 08:59 23.8 — time of reading

Hope this makes sense.
Any help would be appreciated.
Thanks Belinda

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T23:48:26+00:00Added an answer on May 23, 2026 at 11:48 pm

    I managed to work this one out!! A new field LogDate2 was added and LogDate was converted from Nvarchar to a DateTime datatype and populated with LogDate’s values.

    As some LINQ functions aren’t available using Entity Framework e.g. LogDate.Day or LogDate.Month I used EntityFunctions which provided the ability to use CLR methods.

    See EntityFunctions

    So, the new code below works perfectly. It may not be the best or most efficent way to do it, but it provides the correct results.

    var q = from c in context.Wxlogs
                   where
                   c.LogYear == year && c.LogMonth == mm && c.LogTime.Contains("08:59")
                   orderby c.LogDate2
                    let dm = EntityFunctions.AddDays(c.LogDate2, -1)
                    select new {dm, c.Rain_today};
    

    A big thanks to everyone who steered me in the right direction

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a SQL Server 2008 R2 table with nvarchar(4000) field. Data that stores
I have a Microsoft SQL Server 2008 query that returns data from three tables
I have data coming in from datastage that is being put in our SQL
Is there a query in SQL Server 2008 which will delete data from all
In a given SQL Server 2008 table I have a disabled foreign key constraint
I have a couple of tables in a SQL 2008 server that I need
I have tried SQL Server 2008 Management Studio and other third party tools to
Our database server is a SQL 2008 server. My colleagues all have XP service
I have looked at the SQL Server 2008 feature comparison matrix and it lists
I have two named instances of SQL Server 2008 and am trying to set

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.